Advertisement
math230

array size determination

Sep 16th, 2015
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.50 KB | None | 0 0
  1. #include<stdio.h>
  2. //example of array size determination:  sizeof(list) will NOT work by itself
  3. int main()
  4. {
  5.   int i=0;
  6.   char name[] = "cool";
  7.   int list[] = {1,2,3,4,5,6,7,8};
  8.  
  9.    //printf("");
  10.   for(i=0; i<5; i++)
  11.     printf("the characters are %x \n", name[i]);
  12.  
  13.   printf("the character for termination of strings: %d  \n",'\0');
  14.   printf("The size of the array is %d \n", sizeof(list)/sizeof(int)  );
  15.   printf("The size of the array is %d", sizeof(name)/sizeof(char)  );
  16.  
  17.   return 0;
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement