0020-strncmp.c (589B)
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 puts("testing"); 16 17 assert(strncmp("abc", "abc", 3) == 0); 18 assert(strncmp("abcd", "abce", 3) == 0); 19 assert(strncmp("abc", "abc", 4) == 0); 20 assert(strncmp("abcd", "abef", 4) < 0); 21 assert(strncmp("abcf", "abcd", 4) > 0); 22 assert(strncmp("abc", "abe", 0) == 0); 23 assert(strncmp("", "", 1) == 0); 24 assert(strncmp("abc", "", 3) > 0); 25 assert(strncmp("", "abc", 3) < 0); 26 27 puts("done"); 28 29 return 0; 30 }