[tag][\tag]friends when i try to compile this code i get this errorerror: expected identifier or ‘(’ before ‘&’ tokenCode:int main(){int i;int*p;i=5;int &r=i;printf("%d",r);}
[tag][\tag]friends when i try to compile this code i get this errorerror: expected identifier or ‘(’ before ‘&’ tokenCode:int main(){int i;int*p;i=5;int &r=i;printf("%d",r);}
Not everything has to be on one line ._.
And I'm assuming you have no idea how to use pointers, given that you're usinginstead ofCode:int &r=i;Code:int *r = &i;
It would be better if you formatted your code such that each statement is on a separate line, e.g.,
Now, observe this line:Code:int main() { int i; int*p; i=5; int &r=i; printf("%d",r); }
This is invalid C syntax. It is valid C++ syntax, but C++ is not C.Code:int &r=i;
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)
Is valid in C++ which has reference variables, not in C.Code:int &r = i;
And yes, format your code like a normal person.
also, if you are not using a C99 compiler, you will get an error if you have a declaration after executable code.
i=5;int &r=i; (even if &r was legal)