"evaluate parameter more than once"

D

dam_fool_2003

Friends,
I come across a resent thread describes the differences between
getc() vs fgetc().
There some body stated the sentence "evaluate its parameter more than
once".
I cannot understand the word ‘evaluate' in the message. The poster
also gives a
Example for the sentence, which is hard for me to understand. I
searched the FAQ
and I think I have missed it. The thread's link is:


http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&safe=off&th=ffce63752c2c8e1d&rnum=1


Thanks
 
P

pete

Friends,
I come across a resent thread describes the differences between
getc() vs fgetc().
There some body stated the sentence
"evaluate its parameter more than once".
I cannot understand the word ‘evaluate' in the message.

The sizeof operator does *not* evaluate it's operand.
The printf function *does* evaluate it's arguments.

If you have
char x = 0;
and then also
printf("%u, ", (unsigned)sizeof ++x); /* x is not incremented */
printf("%d, ", x); /* x is not incremented */
printf("%d\n", ++x); /* x is incremented */
.... then the output will be:
1, 0, 1
 
R

Ravi Uday

pete said:
The sizeof operator does *not* evaluate it's operand.
The printf function *does* evaluate it's arguments.

If you have
char x = 0;
and then also
printf("%u, ", (unsigned)sizeof ++x); /* x is not incremented */
printf("%d, ", x); /* x is not incremented */
printf("%d\n", ++x); /* x is incremented */
... then the output will be:
1, 0, 1


To whatever value (within SCHAR_MAX and MIN)'x' initialized to - the
first printf always prints *1*

- Ravi
 

Ask a Question

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.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,020
Latest member
GenesisGai

Latest Threads

Top