at what point should I pass a pointer to data in my functions / methods, and not just pass a value?
Obviously, there are cases when I want the function to work on the given data, but what if I just pass the value for information / copy purposes?
For example, foo as the base type:
void setFoo(int foo); ... int foo = 1; setFoo(foo);
Now foo is like a simple structure:
typedef struct { int x; int y; } Foo; void setFoo(Foo foo); ... Foo foo = {1, 2}; setFoo(foo);
But what if foo is a big structure ...
typedef struct { int x; int y; int z; char str[256]; } Foo; void setFoo(Foo *foo);
Q. At what point should I start using a pointer when providing data to a function?
thanks
source share