For example:
int a = 5;
int &b = a;
++b;
b and a are both 6
Greetings
This is a discussion on Does C also have reference parameters within the C Programming forums, part of the General Programming Boards category; For example: int a = 5; int &b = a; ++b; b and a are both 6 Greetings...
For example:
int a = 5;
int &b = a;
++b;
b and a are both 6
Greetings
Use a const pointer, e.g.,
Code:int a = 5; int *const b = &a; ++(*b);
C + C++ Compiler: MinGW port of GCC
Version Control System: Bazaar
Look up a C++ Reference and learn How To Ask Questions The Smart Way
C does not have references and probably never will. It's that kind of language.
But fret not, it has and always will have pointers which can do everything references can and more, albeit in a slightly more complicated way.
Last edited by Elysia; 09-28-2010 at 01:14 AM.
For information on how to enable C++11 on your compiler, look here.
よく聞くがいい!私は天才だからね! ^_^
Heh, they(pointers) could be a headache if stuff like this was abused:
Heh, ptr is also validCode:int value = 5; int *foo = &value; int **bar = &foo; int ***baz = &bar // Or how about int ******ptr; printf("%d",***baz);
But for the sake of being on topic, as Elysia has already said, C has pointers and pass by value. No pass by reference like in C++