Hello,

I am having trouble with seemingly correct printf statements being reported by the compiler (Bloodshed Dev C++) as invalid. I am writing in C, and yes, the file type is set to C as well.

The statements are:
22. printf("This document contains");
23. printf("%d",words);
24. printf("words");

And the errors:
22 wordcount.c syntax error before string constant
22 wordcount.c conflicting types for 'printf'
22 wordcount.c a parameter list with an ellipsis can't match an empty parameter name list declaration
22 wordcount.c conflicting types for 'printf'
22 wordcount.c a parameter list with an ellipsis can't match an empty parameter name list declaration
22 wordcount.c [Warning] data definition has no type or storage class
23 wordcount.c syntax error before string constant
23 wordcount.c [Warning] data definition has no type or storage class
24 wordcount.c syntax error before string constant
24 wordcount.c [Warning] data definition has no type or storage class

I honestly don't understand the problems here. Initially, I could understand it was reporting problems as I had the 'words' variable on line 23 declared as a char earlier in the program. But I changed that to int, and added the %d conversion character to enforce that. I have the two strings in lines 22 and 24 wrapped in double quotes. I don't understand the error about the definition type, and there are no syntax errors, at least as far as I can see with my admittedly limited knowledge of C.

If anyone can help here I'd be grateful. I've tried looking through 'C by Example' and 'C in a Nutshell' and the syntax here matches the examples in those books.

Thanks in advance.

Hussein.