Warning: Declaration of action_plugin_changes::register($controller) should be compatible with DokuWiki_Action_Plugin::register(Doku_Event_Handler $controller) in /volume1/web/dokuwiki/lib/plugins/changes/action.php on line 0 Warning: Declaration of syntax_plugin_code::handle($aMatch, $aState, $aPos, &$aHandler) should be compatible with DokuWiki_Syntax_Plugin::handle($match, $state, $pos, Doku_Handler $handler) in /volume1/web/dokuwiki/lib/plugins/code/syntax.php on line 42 Warning: Declaration of syntax_plugin_code::render($aFormat, &$aRenderer, &$aData) should be compatible with DokuWiki_Syntax_Plugin::render($format, Doku_Renderer $renderer, $data) in /volume1/web/dokuwiki/lib/plugins/code/syntax.php on line 42 c_mystrcomp [Protocol Engineering Lab.]

User Tools

Site Tools


c_mystrcomp
/* mystrcomp.c: comparing the strings */
#include <stdio.h>
 
int mystrcomp(char *s1, char *s2);
 
int main(void) {
    char s[] = "Hello guys!";
    char ss[] = "It's a good day, isn't it?";
    int result;
 
    result = mystrcomp(s, ss);
 
    if(result == 0)
        printf("those are the same\n");
    else
        printf("those are different\n");
 
    return(0);
}
 
int mystrcomp(char *s1, char *s2) {
    char *p1 = &s1[0], *p2 = &s2[0];
 
    while(1)
    {
        if(*p1 != *p2)
            return *p1 - *p2;
        if(*p1 == '\0' || *p2 == '\0')
            return 0;
        p1++;
        p2++;
    }
}
c_mystrcomp.txt · Last modified: 2015/02/07 19:01 by jonghyouk