G
goacross
If you're going to post code here, please make sure it's C, not C++.
It's also helpful to post a (small) complete program rather than an
isolated snippet.
'cout', '<<', and 'endl' are specific to C++.
Your underlying question happens, in this particular case, to be
equally valid in both languages, but there are subtle differences
between C and C++ that even the C experts here may not be aware of.
Just this once, I'll show you a C version of your program.
#include <stdio.h>
int main(void)
{
char ch = 'a';
int v = sizeof ++ch;
printf("%c\n", ch);
return 0;
}
Next time, please either post C in the first place, or post to
comp.lang.c++. If you're having trouble knowing the difference, you
need to learn one language or the other (perhaps eventually both).
A newsgroup is not a good place to do that, but
alt.comp.lang.learn.c-c++ might be more appropriate for your purposes
than comp.lang.c.
Several people have already given you the answer to your question --
which is unfortunate, since the question looks very much like
homework. An expression like 'sizeof ++ch' isn't something that you'd
write if your goal is to accomplish something. It was almost
certainly written by someone trying to make a specific point.
If you want us to do your homework for you, please post your
instructor's e-mail address so we can submit our solutions directly.
We're willing to provide hints if you've done some of the work
yourself and you're stuck on something, but we won't (usually) do it
for you.
--
Keith Thompson (The_Other_Keith) (e-mail address removed) <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
Thanks for your detailed illustration.
However, unfortunately , this is NOT any homework.
Just some personal interest.
Suggest you be more tolerant to freshmen, even if you're expert. I'm
sorry to say you seemed to like a bear with a sore head from the above
words.
Of course, I'm sorry about the cout issue.