Advertisement
teknoraver

array size

Sep 6th, 2018
264
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.52 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. /*
  4.  * $ gcc -Wall size.c -o size.o
  5.  * $ nm -S size.o |grep -w D
  6.  * 0000000000000000 0000000000000007 D s1
  7.  * 0000000000000007 0000000000000006 D s2
  8.  * 000000000000000d 0000000000000006 D s3
  9.  * $ ./size
  10.  * s1      7
  11.  * s2      6
  12.  * s3      6
  13.  */
  14.  
  15. char s1[] = "123456";
  16. char s2[6] = "123456";
  17. char s3[] = {'1', '2', '3', '4', '5', '6'};
  18.  
  19. int main(int argc, char *argv[])
  20. {
  21.  
  22.     printf("s1  %lu\n", sizeof(s1));
  23.     printf("s2  %lu\n", sizeof(s2));
  24.     printf("s3  %lu\n", sizeof(s3));
  25.  
  26.     return 0;
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement