scc

simple c99 compiler
git clone git://git.simple-cc.org/scc
Log | Files | Refs | README | LICENSE

0026-strstr.c (492B)


      1 #include <assert.h>
      2 #include <stdio.h>
      3 #include <string.h>
      4 
      5 /*
      6 output:
      7 testing
      8 done
      9 end:
     10 */
     11 
     12 int
     13 main()
     14 {
     15 	char buf[30] = "abc";
     16 
     17 	puts("testing");
     18 	assert(strstr(buf, "abc") == buf);
     19 	assert(strstr(buf, "bc") == buf + 1);
     20 	assert(strstr(buf, "c") == buf + 2);
     21 	assert(strstr(buf, "d") == NULL);
     22 	strcpy(buf, "ababc");
     23 	assert(strstr(buf, "abc") == buf+2);
     24 	assert(strstr("", "abc") == NULL);
     25 	assert(strstr("abc", "") == NULL);
     26 	assert(strstr("", "") == NULL);
     27 	puts("done");
     28 
     29 	return 0;
     30 }
     31