<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[strend]]></title><description><![CDATA[<p dir="auto">Hello, voici un petit exercice, tiré du livre "The C Programming Language" (K&amp;R).</p>
<p dir="auto">En suivant ce prototype (vous  pouvez changer le nom des paramètres) :</p>
<pre><code>int strend(char *s, char *t)
</code></pre>
<p dir="auto">Créez une fonction qui retourne 1 si la string <em>s</em> se termine par la string <em>t</em>,sinon, retourne 0.</p>
<p dir="auto">Exemples :</p>
<pre><code>strend("ABCDavy","Davy"); // == 1
strend("Melinyel","oyel"); // == 0
strend("Microsoft","sofa"); // == 0
strend("Forum","rum"); // == 1
</code></pre>
<p dir="auto">Je posterais ma solution mardi  <img src="http://new.melinyel.net/assets/plugins/nodebb-plugin-emoji/emoji/android/1f642.png?v=aa95655114f" class="not-responsive emoji emoji-android emoji--slightly_smiling_face" style="height:23px;width:auto;vertical-align:middle" title=":)" alt="🙂" /></p>
]]></description><link>http://new.melinyel.net/topic/779/strend</link><generator>RSS for Node</generator><lastBuildDate>Thu, 21 May 2026 19:15:54 GMT</lastBuildDate><atom:link href="http://new.melinyel.net/topic/779.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 02 Jun 2014 02:09:02 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to strend on Wed, 04 Jun 2014 19:37:30 GMT]]></title><description><![CDATA[<p dir="auto">Suffit d'un peu de relecture <img src="http://new.melinyel.net/assets/plugins/nodebb-plugin-emoji/emoji/android/1f609.png?v=aa95655114f" class="not-responsive emoji emoji-android emoji--wink" style="height:23px;width:auto;vertical-align:middle" title=";)" alt="😉" /></p>
<p dir="auto">Ta fonction <em>my_strlen</em> n’incrémente pas le pointeur <em>str</em>, donc si le premier caractère n'est pas '\0' ça fait une boucle infinie.</p>
]]></description><link>http://new.melinyel.net/post/8365</link><guid isPermaLink="true">http://new.melinyel.net/post/8365</guid><dc:creator><![CDATA[davydavek]]></dc:creator><pubDate>Wed, 04 Jun 2014 19:37:30 GMT</pubDate></item><item><title><![CDATA[Reply to strend on Wed, 04 Jun 2014 18:58:37 GMT]]></title><description><![CDATA[<pre><code>#include &lt;stdio.h&gt;
#include &lt;string.h&gt;

int my_strend(char *s, char *t);
int my_strlen(char *str);

int main()
{
    int *result;

    result[0] = my_strend("TEST", "ST");
    result[1] = my_strend("Melinyel", "Forum");

    printf("%d\n", result[0]);
    printf("%d\n", result[1]);

    return (0);
}

int my_strend(char *s, char *t)
{
    int lenght_s;
    int lenght_t;
    int i;
    int j;

    lenght_s = strlen(s);
    lenght_t = strlen(t);
    j = 0;

    // On regarde si les dernières lettres de "s" correspondent à "t".
    for (i = lenght_s - lenght_t; i &lt; lenght_s; i++)
    {
        if (s[i] != t[j])
            return (0);

        j++;
    }

    return (1);
}

int my_strlen(char *str)
{
    int lenght;

    for (lenght = 0; str != "\0"; lenght++);

    return lenght;
}
</code></pre>
<p dir="auto">Voila mon code mais j'ai un problème avec ma fonction "my_strlen", il faut que je regarde ça de plus près :unsure:</p>
]]></description><link>http://new.melinyel.net/post/8364</link><guid isPermaLink="true">http://new.melinyel.net/post/8364</guid><dc:creator><![CDATA[Soulalex]]></dc:creator><pubDate>Wed, 04 Jun 2014 18:58:37 GMT</pubDate></item><item><title><![CDATA[Reply to strend on Wed, 04 Jun 2014 14:17:14 GMT]]></title><description><![CDATA[<p dir="auto">Merci d'avoir pris la peine d'avoir fait un exercice, je ne l'avais pas vu cependant c'est une très bonne initiative et très pédagogique. <img src="http://new.melinyel.net/assets/plugins/nodebb-plugin-emoji/emoji/android/1f642.png?v=aa95655114f" class="not-responsive emoji emoji-android emoji--slightly_smiling_face" style="height:23px;width:auto;vertical-align:middle" title=":)" alt="🙂" /><br />
Pour la peine, je vous donne un point de réputation aux deux protagonistes de la discussion (et aussi parce qu'il y a Mint dans la signature).</p>
<p dir="auto">Good job !</p>
]]></description><link>http://new.melinyel.net/post/8356</link><guid isPermaLink="true">http://new.melinyel.net/post/8356</guid><dc:creator><![CDATA[Azad]]></dc:creator><pubDate>Wed, 04 Jun 2014 14:17:14 GMT</pubDate></item><item><title><![CDATA[Reply to strend on Wed, 04 Jun 2014 02:34:31 GMT]]></title><description><![CDATA[<p dir="auto">Voici ma solution :</p>
<blockquote>
<p dir="auto">Je sais pas ce qu'il c'est passer avec l'identation ...</p>
<pre><code>int my_strend(const char *str, const char *ending)
{
int lStr = my_strlen(str);
int lEnd = my_strlen(ending);

if(!lStr || !lEnd)
return 0;

const char *iterator = str + lStr - lEnd;
int i = 0;
while(iterator[i] != '\0' &amp;&amp; ending[i] != '\0')
{
if(iterator[i] != ending[i])
{
return 0;
}
i++;
}

return 1;
}
</code></pre>
<p dir="auto">Itère de <em>str - taille d'str + taille de l'ending</em>, jusqu’à la fin de <em>str</em>, en comparant chaque caractère.</p>
</blockquote>
<p dir="auto">Dommage qu'il n'y ai pas eu plus de participants <img src="http://new.melinyel.net/assets/plugins/nodebb-plugin-emoji/emoji/android/1f61e.png?v=aa95655114f" class="not-responsive emoji emoji-android emoji--disappointed" style="height:23px;width:auto;vertical-align:middle" title=":(" alt="😞" /></p>
]]></description><link>http://new.melinyel.net/post/8335</link><guid isPermaLink="true">http://new.melinyel.net/post/8335</guid><dc:creator><![CDATA[davydavek]]></dc:creator><pubDate>Wed, 04 Jun 2014 02:34:31 GMT</pubDate></item><item><title><![CDATA[Reply to strend on Tue, 03 Jun 2014 14:22:52 GMT]]></title><description><![CDATA[<p dir="auto">Voilà, j'ai edit mon code <img src="http://new.melinyel.net/assets/plugins/nodebb-plugin-emoji/emoji/android/1f609.png?v=aa95655114f" class="not-responsive emoji emoji-android emoji--wink" style="height:23px;width:auto;vertical-align:middle" title=";)" alt="😉" /></p>
]]></description><link>http://new.melinyel.net/post/8304</link><guid isPermaLink="true">http://new.melinyel.net/post/8304</guid><dc:creator><![CDATA[AlexMog]]></dc:creator><pubDate>Tue, 03 Jun 2014 14:22:52 GMT</pubDate></item><item><title><![CDATA[Reply to strend on Tue, 03 Jun 2014 02:17:28 GMT]]></title><description><![CDATA[<p dir="auto">@Alex:</p>
<p dir="auto">strstr retourne a la première apparition de t, donc avec ta version :</p>
<pre><code>strend("ABDAVYBD","BD");
</code></pre>
<p dir="auto">retourne 0, alors que ça devrait retourner 1.</p>
]]></description><link>http://new.melinyel.net/post/8285</link><guid isPermaLink="true">http://new.melinyel.net/post/8285</guid><dc:creator><![CDATA[davydavek]]></dc:creator><pubDate>Tue, 03 Jun 2014 02:17:28 GMT</pubDate></item><item><title><![CDATA[Reply to strend on Tue, 03 Jun 2014 14:50:20 GMT]]></title><description><![CDATA[<p dir="auto">OK, amusant, je part du principe qu'on a le droit aux fonctions de la libc, ce qui donnerais:</p>
<pre><code>#include &lt;stdlib.h&gt;

int strend(char *s, char *t)
{
    char *tmp;

    tmp = s;
    while ((tmp = strstr(tmp, t)) != NULL);
    return (tmp != NULL &amp;&amp; strlen(tmp) == strlen(t));
}
</code></pre>
]]></description><link>http://new.melinyel.net/post/8239</link><guid isPermaLink="true">http://new.melinyel.net/post/8239</guid><dc:creator><![CDATA[AlexMog]]></dc:creator><pubDate>Tue, 03 Jun 2014 14:50:20 GMT</pubDate></item></channel></rss>