
-----------------------------------
php111
Sat Jan 10, 2009 6:53 pm

I am doing printf functions. What line is my constant string for syntax?
-----------------------------------
Where is my constant string for syntax? I am getting errors? I am following printf functions. My code has to be right. I know it is right. Why am I getting syntax errors?


Here are the errors:


Microsoft Windows XP 



printf("I am a simple ");

printf("computer.\n");

printf("My favorite number is %d because it is first.\n", num);

-----------------------------------
OneOffDriveByPoster
Sat Jan 10, 2009 9:16 pm

Re: I am doing printf functions. What line is my constant string for syntax?
-----------------------------------
printf("I am a simple ");

printf("computer.\n");

printf("My favorite number is %d because it is first.\n", num);Looks like you got confused because you were using some interactive "C" environment that I won't name.  What you have there is not a valid C program.  You cannot have statements at the top level of your translation unit.  You should have a function called main().  You can have statements in main().

-----------------------------------
wtd
Sun Jan 11, 2009 12:53 am

RE:I am doing printf functions. What line is my constant string for syntax?
-----------------------------------
The "main" function is your C program's "entry point." It's where execution of code starts in any C program.

-----------------------------------
php111
Sun Jan 11, 2009 9:40 am

Re: I am doing printf functions. What line is my constant string for syntax?
-----------------------------------
I was following the code from the book. I did put in int main() I still get errors. I give my code. I also give the code from the book.



int main()

printf("I am a simple ");

printf("computer.\n");

printf("My favorite number is %d because it is first.\n", num);


Here is the code from the book...



printf("I am a simple ");

printf("computer.\n");

printf("My favorite number is %d because it is first.\n", num);

-----------------------------------
Vertico
Sun Jan 11, 2009 11:01 am

Re: I am doing printf functions. What line is my constant string for syntax?
-----------------------------------
You are still missing necessary parts for this to work.

Go back to your book and read through it carefully, not just the small code snippets. Also look back at your previous thread near the end and see what you are missing.

-----------------------------------
[Gandalf]
Sun Jan 11, 2009 3:53 pm

RE:I am doing printf functions. What line is my constant string for syntax?
-----------------------------------
Generally a function in C will look like:
 () 
{
     ;
     ;
     ;
     ;
}
Now keep in mind that main is a function, and think about why your code isn't working.
