fork download
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4.  
  5. #define log(x) printf(#x": %d\n",x)
  6.  
  7. int main(int argc, char *args) {
  8. char s[] = "string";
  9.  
  10. log(sizeof(s));
  11. log(strlen(s));
  12.  
  13. int i;
  14. for (i=0; i<strlen(s); i++) printf("s[%d]: %c(%d)\n", i, s[i], s[i]);
  15. puts("");
  16.  
  17. puts("Null character");
  18. log(s[strlen(s)]); // equal s[6]
  19. log(NULL);
  20. log('\0');
  21. log(0);
  22.  
  23. exit(EXIT_SUCCESS);
  24. }
Success #stdin #stdout 0s 2248KB
stdin
Standard input is empty
stdout
sizeof(s): 7
strlen(s): 6
s[0]: s(115)
s[1]: t(116)
s[2]: r(114)
s[3]: i(105)
s[4]: n(110)
s[5]: g(103)

Null character
s[strlen(s)]: 0
NULL: 0
'\0': 0
0: 0