bhupixb

cm

Aug 12th, 2018
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. 1) Array parameters are always passed as pointers, even when we use square brackets.
  2. 2) https://www.geeksforgeeks.org/references-in-c/
  3. 3) https://www.geeksforgeeks.org/void-pointer-c/
  4. 4) https://www.geeksforgeeks.org/function-pointer-in-c/
  5. #include <stdio.h>
  6.  
  7. int fun(int ptr[])
  8. {
  9. int x = 10;
  10.  
  11. // size of a pointer is printed
  12. printf("sizeof(ptr) = %d\n", sizeof(ptr));
  13.  
  14. // This allowed because ptr is a pointer, not array
  15. ptr = &x;
  16.  
  17. printf("*ptr = %d ", *ptr);
  18.  
  19. return 0;
  20. }
  21. int main()
  22. {
  23. int arr[] = {10, 20, 30, 40, 50, 60};
  24. fun(arr);
  25. return 0;
  26. }
Add Comment
Please, Sign In to add comment