RicardasSim

number of elements in an array

Jul 6th, 2019
735
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.31 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4.  
  5.  
  6. int main()
  7. {
  8.  
  9.     int arr[10]={0};
  10.    
  11.     unsigned int num1, num2;
  12.    
  13.     num1 = sizeof arr/sizeof arr[0];
  14.     num2 = sizeof arr/sizeof *arr;
  15.    
  16.     printf("%d %d\n", num1, num2);
  17.    
  18.     return 0;
  19. }
  20.  
  21. /*
  22. output:
  23.  
  24. 10 10
  25.  
  26. */
Advertisement
Add Comment
Please, Sign In to add comment