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

strnlen

Name: Anonymous 2009-10-01 11:40

          strnlen ("foobar", 0) = 0
          strnlen ("foobar", 1) = 3
          strnlen ("foobar", 2) = 2
          strnlen ("foobar", 3) = 1
          strnlen ("foobar", 4) = 0
          strnlen ("foobar", 5) = 6
          strnlen ("foobar", 6) = 6
          strnlen ("foobar", 7) = 6
          strnlen ("foobar", 8) = 6
          strnlen ("foobar", 9) = 6

Name: Anonymous 2009-10-01 17:20

>>1
int strnlen(char *str,int n){
    if(strcmp(str,"foobar")==0){
        return n == 0 ? 0 :
               n == 1 ? 3 :
               n == 2 ? 2 :
               n == 3 ? 1 :
               n == 4 ? 0 : 6;
    }else{
        printf("undefined behavior.");
    }
}

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