I dont understand what happened in the printf

February 6, 2011 at 05:33:00
Specs: Windows XP
void main()
int i=0;
char s[3][10]={"hello","hows","you"};
printf("%c %c %c",*s,*s[i++],(*s[i++])--);
can u explain in detail what is happenning in the printf statement;???

See More: I dont understand what happened in the printf

Report •

February 6, 2011 at 09:02:13
I'm not quite sure what you mean. Isn't it producing the output that you require (why else would you be asking)? What output does it produce?

It's a very strange printf statement that I would only expect to find in a test question. You're not asking us to do you homework for you, are you?

Report •

February 9, 2011 at 07:31:43
actually it was in the c programming competition so i wanna know how to get the output on paper....

Report •

February 9, 2011 at 08:25:46
What are you expecting? The second parameter is a char*, and you're treating as a char. Also, incrementing i multiple times in printf() might very well be is undefined behavior.

EDIT: Parameter order is not, in fact, defined in the C standard.

How To Ask Questions The Smart Way

Report •
Related Solutions

Ask Question