![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Newbie
Join Date: Jun 2008
Posts: 3
Rep Power: 0
![]() |
syntax error before printf
I would appreciatee your help. It is written in C and is a pizza order form. It is very simple
{
do printf ("Welcome 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 |
|
|
|
|
|
#2 |
|
Hobbyist Programmer
Join Date: Jan 2006
Location: UK
Posts: 215
Rep Power: 3
![]() |
Re: syntax error before printf
you have a stray do before the printf.
|
|
|
|
|
|
#3 |
|
Expert Programmer
Join Date: May 2005
Location: East Lansing, MI
Posts: 663
Rep Power: 4
![]() |
Re: syntax error before printf
and it's \n not /n
|
|
|
|
|
|
#4 |
|
Newbie
Join Date: Jun 2008
Posts: 3
Rep Power: 0
![]() |
thank you
don't believe i missed that
|
|
|
|
|
|
#5 |
|
Newbie
Join Date: Jun 2008
Posts: 3
Rep Power: 0
![]() |
Re: syntax error before printf
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int main()
{
int *tablenumber;
char *pizzabase;
char *pizza;
char *topping;
int *nopizza;
float bill;
float a = 0.50;
float b = 0.50;
float c = 3.50;
float d = 3.70;
float e = 4.00;
float f = 3.40;
float g = 0.75;
float h = 1.00;
float i = 0.45;
{
printf("|---------------------------------|\n");
printf("|Max shaws pizza ordering form |\n");
printf("|25 June Version 1.0 |\n");
printf("|---------------------------------|\n\n");
{
printf ("enter what pizza base you would like choose between\n");
printf ("Thin and Crispy(a) or thick and cheesy(b)\n");
do scanf("%c",&*pizzabase);
while (*pizzabase==a);
while (*pizzabase==b);
{
printf ("please choose a pizza\n");
printf ("vegetarian (c), Meatfeast (d), Seafood (e), Cheese and Tomato (f)\n");
do scanf("%c",&*pizza);
while (*pizza==c);
while (*pizza==d);
while (*pizza==e);
while (*pizza==f);
{
printf ("please choose an extra topping\n");
printf ("anchovies (g), peppers (h), none (i)\n");
do scanf("%c",&*topping);
while (*topping==g);
while (*topping==h);
while (*topping==i);
{
printf ("how many pizzas wuold you like between 1 -10?");
do scanf ("%d", &*nopizza);
while (*nopizza >=11);
while (*nopizza<=0);
{
bill = (*pizzabase + *pizza + *topping) * *nopizza;
printf ("your order will \n");
printf("Total = %d",bill);
{
system ("pause");
return *tablenumber;
return *pizzabase;
return *pizza;
return *topping;
return *nopizza;
return bill;
return 0;
}}}}}}}}More help would be appreciated as everytime I run this it just closes down. comes up with a windows prompt. Im not sure where the problem is. |
|
|
|
|
|
#6 |
|
The Oblivious One
Join Date: May 2005
Location: Ontario, Canada
Posts: 644
Rep Power: 4
![]() |
Re: syntax error before printf
There are two big problems with your code.
1) You have no notion of "standard" indenting and block practises so it is almost completely unreadable. 2) You have several misunderstandings of how the do-while loop works and how C in general works. I was going to rewrite it for you, but I quickly became overwhelmed with the number of mistakes and logic errors. My advice would be to re-read whatever reference you're reading and if you'd like, I'm sure we could all make our own suggestions for recommended resources to help you out. Maybe this will get you started. It's a simple example of a do-while loop. You shouldn't actually use the kind of code to read passwords, but I think it's a nice example. c Syntax (Toggle Plain Text)
If you have any questions, don't be afraid to ask.
__________________
Dr. Zoidberg: [ecstatic] I'm going to a movie... with FRIENDS! Last edited by Jessehk; Jul 2nd, 2008 at 12:07 PM. |
|
|
|
|
|
#7 |
|
Programmer
Join Date: Feb 2008
Location: India
Posts: 58
Rep Power: 1
![]() |
Re: syntax error before printf
Would like to say same as said by jessehk. And also would like to say that start using arrays instead of defining those all floats from a to i. float a[] = {0.5,0.5,3.5,3.75,......};
|
|
|
|
|
|
#8 | |
|
Newbie
Join Date: Aug 2008
Posts: 5
Rep Power: 0
![]() |
Re: syntax error before printf
Quote:
__________________
http://www.echo.net84.net/ |
|
|
|
|
|
|
#9 | ||
|
Caffeinated Neural Net
![]() Join Date: Jun 2005
Location: Dry west coast of Canada
Posts: 1,034
Rep Power: 5
![]() |
Re: syntax error before printf
Quote:
Quote:
Besides, fgets() only returns NULL for error conditions unrelated to user input, such as not being able to read from the stream (unlikely for stdin), whereas scanf() will fail to read data in the wrong format. If you're going to complain about Jessehk not checking for NULL, then you'd better complain about your failure to check scanf()'s return value (which, for the record, is a count of items successfully converted, or EOF on error).
__________________
And once again, Probability proves itself willing to sneak into a back alley and service Drama as would a copper-piece harlot. - Vaarsuvius, Order of the Stick |
||
|
|
|
|
|
#10 |
|
Newbie
Join Date: Aug 2008
Posts: 5
Rep Power: 0
![]() |
Re: syntax error before printf
Right... I don't see scanf() being used in Jessehk's code at all. Besides error checking is always important and I was just trying to make a point that its important to instill good practices.
__________________
http://www.echo.net84.net/ |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| printf Alignment | Sane | C | 13 | Jan 27th, 2008 8:18 PM |
| syntax error in Mysql... | ktsirig | PHP | 1 | Feb 3rd, 2007 1:30 PM |
| Header file internal errors | kruptof | Coder's Corner Lounge | 2 | Jan 14th, 2007 1:12 PM |
| From C syntax to C++ syntax | Navid | C++ | 13 | Jan 15th, 2006 7:42 AM |
| How to say the size of an array using printf ? | colt | C | 2 | May 19th, 2005 3:25 PM |