Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

strstr challenge

Name: Anonymous 2013-08-20 5:21

create the fastest C strstr function implementation.
Rules:
1.Must be portable between different architectures(ARM,x86/x86-64,MIPS)
2.Must handle strings of any length that C standard library strstr can handle.
3.Cannot rely on undefined behavior or platform specific code.
strstr reference: http://www.cplusplus.com/reference/cstring/strstr/

Name: Anonymous 2013-08-25 22:56


char * strstr(char * str1, char * str2){
     while (str1 != "\0"){
           int i=0;
           char * c2 = str2;
           while (str1[i]==c2){
                 c2++;
                 i++;
                 if (c2 == "\0"){
                    return str1;      
                 }
           }
           str1++;     
     }
     return NULL;
}

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List