By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,044 Members | 1,287 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,044 IT Pros & Developers. It's quick & easy.

Unary.c

P: 2
printf("\n%d %d", a--, --b);

This is supposed to be ok, but it gives me this compiler error=

Parse error before string constant.
conflicting types for built-in function 'printf'
/* unary.c*/
/* Demonstrate unary operator prefix and postfix modes */

#include <stdio.h>

int a, b;

main(0
{
/* set a and b both equal to 5 */

a = b = 5;

/* Print them, decrementing each time. /*
/* Use prefix mode for b, postfix mode for a */

printf("\n%d %d", a--, --b);
printf("\n%d %d", a--, --b);
printf("\n%d %d", a--, --b);
printf("\n%d %d", a--, --b);
printf("\n%d %d", a--, --b);

return 0;

}
Sep 14 '06 #1
Share this Question
Share on Google+
4 Replies


100+
P: 144
printf("\n%d %d", a--, --b);

This is supposed to be ok, but it gives me this compiler error=

Parse error before string constant.
conflicting types for built-in function 'printf'
/* unary.c*/
/* Demonstrate unary operator prefix and postfix modes */

#include <stdio.h>

int a, b;

main(0
{
/* set a and b both equal to 5 */

a = b = 5;

/* Print them, decrementing each time. /*
/* Use prefix mode for b, postfix mode for a */

printf("\n%d %d", a--, --b);
printf("\n%d %d", a--, --b);
printf("\n%d %d", a--, --b);
printf("\n%d %d", a--, --b);
printf("\n%d %d", a--, --b);

return 0;

}

This code works fine for me except for the typo "main(0" which I assume should be "main()". Are you sure you had the #include <stdio.h> in your file when you tried to compile this? The compiler error looks like what you would get if you forgot to include the standard IO library.
Sep 14 '06 #2

P: 2
Thankyou
Yes typo error.
Yes I use #include.
Coulod it be the compiler?
Sep 14 '06 #3

P: 23
#include <stdio.h>

int a, b;

main(0
{
/* set a and b both equal to 5 */

a = b = 5;

/* Print them, decrementing each time. /*
/* Use prefix mode for b, postfix mode for a */

printf("\n%d %d", a--, --b);
printf("\n%d %d", a--, --b);
printf("\n%d %d", a--, --b);
printf("\n%d %d", a--, --b);
printf("\n%d %d", a--, --b);

return 0;

}

the code works fine for me too,except main(0)...could be a typo ? :-)
Sep 15 '06 #4

P: 11
nt a, b;

main()
{
/* set a and b both equal to 5 */

a = b = 5;

/* Print them, decrementing each time. /*
/* Use prefix mode for b, postfix mode for a */

printf("\n%d %d", a--, --b);
printf("\n%d %d", a--, --b);
printf("\n%d %d", a--, --b);
printf("\n%d %d", a--, --b);
printf("\n%d %d", a--, --b);

return 0;

}
this code worked perfectly for me if we cahnge the main(0) to main() then it works all right
Sep 15 '06 #5

Post your reply

Sign in to post your reply or Sign up for a free account.