G
Guest
I saw this code in C++ but when tried to C causes an error:
I saw this code in C++ but when tried to C causes an error:
- Chameleon - said:I saw this code in C++ but when tried to C causes an error:
-------------
void function(int &a) { a = 5; }
-------------
with this, passed in "function" the "a" pointer instead of "a" value, BUT
inside "function" I have access to "a" value not with "*a" but with "a".
Why this is not working in C?
In said:I saw this code in C++ but when tried to C causes an error:
-------------
void function(int &a) { a = 5; }
-------------
with this, passed in "function" the "a" pointer instead of "a" value, BUT
inside "function" I have access to "a" value not with "*a" but with "a".
Why this is not working in C?
I won't get into references here as this newsgroup is for the C standard,
not C++
a different language. Here are some other things that won't work:
$a =~ s/\d+/$1+1/eg;
0 -72 -72 0 0 72 72 0 4 72 72 moveto { rlineto } repeat stroke
if (a instanceof java.lang.String) System.out.println((String) a);
... and so on ...
Why isn't Fortran syntax working in C?
Why isn't Pascal syntax working in C?
Why isn't Perl syntax working in C?
And so on, and so on, and so on...
Next time, try engaging your brain before posting a question. It doesn't
(or, at least, shouldn't) hurt.
Greg P. said:| Because it's nonsense. '(int &a)' is a syntax error. If you want to do
| this in C, write in C instead of using the pointless syntactic sugar
| introduced in C++ for people too stupid to write C:
I half agree with that statement as I find templates a break from thousands
of lines of code (which are only C++). But I also find that references are a
lazy way of lacking pointer knowledge.
I saw this code in C++ but when tried to C causes an error:
-------------
void function(int &a) { a = 5; }
-------------
with this, passed in "function" the "a" pointer instead of "a" value, BUT
inside "function" I have access to "a" value not with "*a" but with "a".
Why this is not working in C?
Greg said:| Because it's nonsense. '(int &a)' is a syntax error. If you want to do
| this in C, write in C instead of using the pointless syntactic sugar
| introduced in C++ for people too stupid to write C:
I half agree with that statement as I find templates a break from thousands
of lines of code (which are only C++). But I also find that references are a
lazy way of lacking pointer knowledge.
I saw this code in C++ but when tried to C causes an error:
-------------
void function(int &a) { a = 5; }
-------------
with this, passed in "function" the "a" pointer instead of "a" value, BUT
inside "function" I have access to "a" value not with "*a" but with "a".
Why this is not working in C?
I saw this code in C++ but when tried to C causes an error:
-------------
void function(int &a) { a = 5; }
-------------
with this, passed in "function" the "a" pointer instead of "a" value, BUT
inside "function" I have access to "a" value not with "*a" but with "a".
Why this is not working in C?
Martijn said:Why all these offensive responses? It is a legitimate question which only
Greg seems to take this seriously. All those "witty" responses are more
cluttering than the original post.
I guess it is true what they say: "There are no stupid questions, only
stupid answers"
If you are going to do work in C, get a book and learn it. Otherwise you
just waste your time and ours.
I work in C for 2,5 years
I learned C day by day from other C sources
from help pages
and from this newsgroup
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.