Error Syntax Error Before Printf
Contents |
Page... Page 1 of 2 1 2 > Thread Tools Display Modes Jun 22nd, 2008, 9:09 AM syntax error before numeric constant #1 ifcaps(on):loop Newbie Join Date: Jun 2008 Posts: 3 Rep syntax error before or at eof Power: 0 syntax error before printf I would appreciatee your help. It is written in C and syntax error before else is a pizza order form. It is very simple (Toggle Plain Text) { do printf ("Welcome and please follow instruction to order/n"); printf ("enter your table number 1-25");
Syntax Error Before String Constant
//---> it says syntax error before printf here scanf ("%d", tablenumber); if (tablenumber > 25); return tablenumber; { ______________________________________ { bill = (6.50 + .50) *nopizzas; printf ("your order will cost",bill); return 0; }}}}}} // C:\Users\Digit0ljedi\Desktop\sdgf\Makefile.win [Build Error] n\make.exe: *** ["order form.o"] Error 1 //is this a a computer error or still code { do printf ("Welcome error syntax error before token and please follow instruction to order/n"); printf ("enter your table number 1-25"); //---> it says syntax error before printf here scanf ("%d", tablenumber); if (tablenumber > 25); return tablenumber; { ______________________________________ { bill = (6.50 + .50) *nopizzas; printf ("your order will cost",bill); return 0; }}}}}} // C:\Users\Digit0ljedi\Desktop\sdgf\Makefile.win [Build Error] n\make.exe: *** ["order form.o"] Error 1 //is this a a computer error or still code thank you in advance ifcaps(on):loop View Public Profile Find More Posts by ifcaps(on):loop Jun 22nd, 2008, 10:36 AM #2 Seif Professional Programmer Join Date: Jan 2006 Location: UK Posts: 265 Rep Power: 11 Re: syntax error before printf you have a stray do before the printf. Seif View Public Profile Find More Posts by Seif Jun 22nd, 2008, 10:49 AM #3 OpenLoop Expert Programmer Join Date: May 2005 Location: East Lansing, MI Posts: 712 Rep Power: 12 Re: syntax error before printf and it's \n not /n OpenLoop View Public Profile Find More Pos
feedback Answers Home All Categories Arts & Humanities Beauty & Style Business & Finance Cars & Transportation Computers & Internet Consumer Electronics Dining Out Education & Reference Entertainment & Music Environment Family & syntax error before token dev c++ Relationships Food & Drink Games & Recreation Health Home &
Erlang Syntax Error Before
Garden Local Businesses News & Events Pets Politics & Government Pregnancy & Parenting Science &
Scanf Syntax In C Example
Mathematics Social Science Society & Culture Sports Travel Yahoo7 Products International Argentina Brazil Canada France Germany India Indonesia Italy Malaysia Mexico New Zealand Philippines http://www.programmingforums.org/thread16043.html Quebec Singapore Taiwan Hong Kong Spain Thailand UK & Ireland United States Vietnam Espanol About About Answers Community Guidelines Leaderboard Knowledge Partners Points & Levels Blog Safety Tips Computers & Internet Programming & Design Next Syntax error before printf? include here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of http://stackoverflow.com/questions/3723768/help-with-c-scanf-syntax this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask https://courses.cs.washington.edu/courses/cse142/info/syntaxErr.html Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up syntax error Help with C scanf syntax up vote 3 down vote favorite When I run the following snippet it runs until the second question. It then puts the "Is the customer a student? (y/n) \n" and "What is the movies time? (in hours) \n" prompts together (no area to answer between them). If one takes any action from there on, the program stops working. syntax error before What did I do wrong? (i'm pretty sure it's syntax related) int A,B,C,D,age,time; char edu, ddd; printf ("What is the customer's age? \n"); scanf("%d", &age); printf ("Is the customer a student? (y/n) \n"); scanf("%c", &edu); printf ("What is the movies time? (in hours) \n"); scanf("%d", &time); printf ("Is the movie 3-D? (y/n) \n"); scanf("%c", &ddd); c syntax share|improve this question asked Sep 16 '10 at 4:42 rectangletangle 8,68645122204 2 This might be helpful. –sje397 Sep 16 '10 at 4:45 1 It's better to just avoid scanf: c-faq.com/stdio/scanfprobs.html –jamesdlin Sep 16 '10 at 5:52 add a comment| 6 Answers 6 active oldest votes up vote 3 down vote accepted You probably need to eat the extra input from stdin after each scanf so it doesn't stick around in the buffer and cause scanf to receive the buffered data. This is because the newline from hitting enter after the first text entry stays in the buffer and is a valid entry for the "%c" format - if you look at the value of "edu" you should find it's a newline character. share|improve this answer answered Sep 1 cause(s) and a possible fix. Please note that you may get the same error or warning for totally different reasons. If you got one or more of the listed warnings, do NOT ignore them. fatal error C1004: unexpected end of file found error C2001:newline in constant error C2017: illegal escape sequence error C2059: syntax error : 'type' / syntax error : ';' error C2059: syntax error : '}' error C2059: syntax error : ')' error C2143: syntax error : missing ';' before 'type' error C2146: syntax error : missing ')' before identifier 'i' (at printf statements) error C2296: '%' : illegal, left operand has type 'const double ' error C2297: '%' : illegal, right operand has type 'const double ' error C2100: illegal indirection error C2106: '=' : left operand must be l-value error C2371: 'func' : redefinition; different basic types warning C4029: declared formal parameter list different from definition warning C4013: 'func' undefined; assuming extern returning int warning C4715: 'func' : not all control paths return a value warning C4700: local variable 'i' used without having been initialized warning C4047: '=' : differs in levels of indirection warning C4005: macro redefinition fatal error C1004: unexpected end of file found This usually means that you are missing a close curly bracket ( }) near the end of the file. Double check that your curly brackets are matching. error C2001: newline in constant This error is usually caused by syntax error at printf statements. Possibilities: 1) missing a close quotation ( " ) at the end of the string that you want to print. example: printf ( " string I want to print ); 2) the string is span over 2 or more lines (separated by return character, or you have hit return to break the string into 2 or more lines) example: printf ( " continue printing, don't want a wrap around on printout " ) ; fix: a) add in quotation marks printf ( " constinue printing, " " don't want to wrap around on printout " ) ; b) 2 separate printfs printf ( " continue printing, " ) ; printf ( " don't want to wrap around on printout " ) ; error C2017: illegal escape sequence Chances are you have a misplaced escape character like " \n " or " \t ". example: "\n" is placed outside quotation of a printf statement. printf ( " printing " \n ); fix: printf ( " printing \n " ); error C2059:syntax error