I know, the title is a little bit odd. Of course I know how to do call-by-reference in C. My problem is simple and the solution could be simple as well. I am currently going through some scripts of my university and they explicitly write "Call-By-Reference is NOT used in C".
Since I (think I) know how to do call by reference in C, i am a little bit confused and hope you can help me out.
Do I generally understand something wrong about the term Call-By-Reference? Or is the code below actually call-by reference
void test(int* p) {
*p = 5;
}
int main(int argc, char *argv[]) {
int i = 2;
test(&i);
printf("i = %i\n",i);
end;
}
Another explanation would be that call-by-reference is bad practice. For example Java does not allow call by reference for non objects. But since C is nor object oriented it makes no sense to me (beside maybe with structs)
Or is the script actually wrong?
Thank you in advance!