0022-strnlen.c (295B)
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 assert(strnlen("", 2) == 0); 17 assert(strnlen("abc", 10) == 3); 18 assert(strnlen((char[3]) {"abc"}, 3) == 3); 19 assert(strnlen("abc", 2) == 2); 20 puts("done"); 21 22 return 0; 23 }