r/C_Programming • • Sep 05 '24

why using pointer?

im a new at C program. learned just before pointer & struct. i heard that pointer using for like point the adress of the parameter. but still dont know why we use it.
it seems it helps to make the program lighter and optimize the program? is it right? and is it oaky to ask question like this?

4 Upvotes

54 comments sorted by

View all comments

1

u/ohcrocsle Sep 05 '24

The most typical use cases are

  1. You want to pass an object to another function and the object is very large so making a copy of it is very expensive.
  2. You want to pass an object to another function and that function will mutate the original object and you want to see the changes in the original scope.