Lvalue required in function main

This is a discussion on Lvalue required in function main within the C Programming forums, part of the General Programming Boards category; am....first of all i just would like you to all to know that im just a beginner in C programming ...

  1. #1
    Registered User
    Join Date
    Sep 2008
    Posts
    5

    Lvalue required in function main

    am....first of all i just would like you to all to know that im just a beginner in C programming so please understand if my codes to loooong whe've just discuss
    about arrays, pointer, and functions last week.......

    here's my code with an error:
    Code:
                                                    case 1:order="Strawberry Sundae";break;
    			case 2:order="Hot Caramel Sundae";break;
    			case 3:order="Hot Fudge Sundae";break;
    			case 4:order="Vanilla IceCream";break;
    			case 5:order="COke Float";break;
    Our prof wants us to make a program that receives orders in a fast food chanin
    and display a receipt complete with all info and the orders.....

    i have already written the code but my problem is that it only prints the last order i've entered it is supposed to print all orders T_T

    and i've decided to use an array of strings to store all the orders and call it at the receipt part to print all the orders it stored..

    declaration:
    Code:
                    char order[50];  // i've stored all order in the variable order
    	char or[]={ };
    here the part to store the orders in the array:
    Code:
                    for(r=0;r<100)
    		{
    			or[r]=order;
    			r++;
    
    		              other:
    		              clrscr();
    		              getch();
    		              gotoxy(26,12);textcolor(YELLOW);cprintf(" Do u hav another order? [Y/N]");
    		              gotoxy(26, 13);textcolor(YELLOW);cscanf("%c", &ans);
    		                if(ans=='y' || ans=='Y')
    		                 {
    		                		clrscr();
    				                goto category;
    		                  }
    		                  else 
    				goto sub;
    here the part to print all the orders:
    Code:
    		for(j=0;j<100;j++)
    			printf("%s",or[j]);
    i really need ur help guys T___T
    thanks

  2. #2
    and the hat of sweating
    Join Date
    Aug 2007
    Location
    Toronto, ON
    Posts
    3,545
    Code:
    or[r]=order;
    This is not how you copy strings. This is trying to copy a pointer into a single char and your compiler should be screaming its head off when it sees this.

    Also, get rid of the goto's. As far as students are concerned, goto is EVIL and should never be used. Plus your teacher should be complaining if he sees them in your code.
    "I am probably the laziest programmer on the planet, a fact with which anyone who has ever seen my code will agree." - esbo, 11/15/2008

    "the internet is a scary place to be thats why i dont use it much." - billet, 03/17/2010

  3. #3
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Posts
    22,993
    Code:
    order="Hot Caramel Sundae";break;
    Nor will this ever work either.
    order is an array, but you assigning (or trying) a const char* to it.
    You need to copy a string? Use strcpy.

    And just for curiosity, how does your main look and your input (code)?
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  4. #4
    Registered User
    Join Date
    Sep 2008
    Posts
    5
    ill just paste my whole code here but its really quite long T__T
    Code:
    #include<stdio.h>
    #include<ctype.h>
    #include<conio.h>
    main()
    {
    	int z,i,x;
    	int s=0,f=0,sal=0,b=0,d=0,bev=0;
    	int v_meal,f_size,cat,quantity;
    	float price,subtotal=0,cash,change,vat;
    
    	char pwd,ans,add_up;
    	char pass[10];
    
    	password:
    		clrscr();
    		i=0;
    	gotoxy(24,9);textcolor(YELLOW);cprintf("Welcome to McDonald's Corporation ");
    	gotoxy(20,10);textcolor(YELLOW);cprintf("Please Enter Password to continue transaction");
    	gotoxy(32,13);textcolor(YELLOW);cprintf("Enter Password ");
    		while((pwd=getch()) !='\r')  {
    			printf("");
    			pass[i]=pwd;
    			i++;
    		}
    		pass[i]='\0';
    
    		if(strcmp(pass,"denise"))
    			goto password;
    		else{
    
    
    	clrscr();
    	gotoxy(29,14);textcolor(YELLOW);cprintf("*");
    	gotoxy(29,13);textcolor(YELLOW);cprintf("*");
    	gotoxy(30,12);textcolor(YELLOW);cprintf("*");
    	gotoxy(31,11);textcolor(YELLOW);cprintf("*");
    	gotoxy(32,10);textcolor(YELLOW);cprintf("*");
    	gotoxy(33,9);textcolor(YELLOW);cprintf("*");
    	gotoxy(34,9);textcolor(YELLOW);cprintf("*");
    	gotoxy(35,10);textcolor(YELLOW);cprintf("*");
    	gotoxy(36,11);textcolor(YELLOW);cprintf("*");
    	gotoxy(37,12);textcolor(YELLOW);cprintf("*");
    	gotoxy(37,13);textcolor(YELLOW);cprintf("*");
    	gotoxy(38,14);textcolor(YELLOW);cprintf("*");
    	gotoxy(39,13);textcolor(YELLOW);cprintf("*");
    	gotoxy(39,12);textcolor(YELLOW);cprintf("*");
    	gotoxy(40,11);textcolor(YELLOW);cprintf("*");
    	gotoxy(41,10);textcolor(YELLOW);cprintf("*");
    	gotoxy(42,9);textcolor(YELLOW);cprintf("*");
    	gotoxy(43,9);textcolor(YELLOW);cprintf("*");
    	gotoxy(44,10);textcolor(YELLOW);cprintf("*");
    	gotoxy(45,11);textcolor(YELLOW);cprintf("*");
    	gotoxy(46,12);textcolor(YELLOW);cprintf("*");
    	gotoxy(47,13);textcolor(YELLOW);cprintf("*");
    	gotoxy(47,14);textcolor(YELLOW);cprintf("*");
    	gotoxy(32,16);textcolor(YELLOW+BLINK);cprintf("pa para papap");
    	gotoxy(33,16);textcolor(YELLOW);cprintf("\nLove ko 'to");
    	getch();
    	}
    
    
    	clrscr();
    		
    	category:
    	gotoxy(15,3);textcolor(YELLOW);cprintf("************ SELECT A MENU CATEGORY ************ ");
    	gotoxy(10,7);textcolor(YELLOW);cprintf("[1] Sandwiches");
    	gotoxy(10,8);textcolor(YELLOW);cprintf("[2] French Fries");
    	gotoxy(10,9);textcolor(YELLOW);cprintf("[3] Salads");
    	gotoxy(10,10);textcolor(YELLOW);cprintf("[4] Breakfast");
    	gotoxy(10,11);textcolor(YELLOW);cprintf("[5] Desserts");
    	gotoxy(10,12);textcolor(YELLOW);cprintf("[6] Beverage");
    
    	gotoxy(10,13);textcolor(YELLOW);cprintf("[7] Combo Meals");
    	gotoxy(27,17);textcolor(YELLOW);cprintf("Meal Category #: ");
    	gotoxy(45,17);textcolor(YELLOW);cscanf("%d", &cat);
    
    	if(cat>7 || cat<=0)
    	{
    		goto category;
    	}
    	else if(cat==1)
    	{
    		clrscr();
    		getch();
    		sand:
    		gotoxy(24,3);textcolor(YELLOW);cprintf("*********** SANDWICHES ************ ");
    		gotoxy(10,7);textcolor(YELLOW);cprintf("[1] Hamburger                     1.00");
    		gotoxy(10,8);textcolor(YELLOW);cprintf("[2] Chessburger                   1.00");
    		gotoxy(10,9);textcolor(YELLOW);cprintf("[3] Double Chessburger            1.00");
    		gotoxy(10,10);textcolor(YELLOW);cprintf("[4] Big Mac                       1.00");
    		gotoxy(10,11);textcolor(YELLOW);cprintf("[5] Filet-O-Fish                  1.00");
    		gotoxy(27,17);textcolor(YELLOW);cprintf("Meal number: ");
    		gotoxy(43,17);textcolor(YELLOW);cscanf("%d", &s);
    		switch(s)
    		{
    			case 1:price=1.00;break;
    			case 2:price=2.00;break;
    			case 3:price=3.00;break;
    			case 4:price=4.00;break;
    			case 5:price=5.00;break;
    		}
    
    		if(s>5 || s<=0)
    		{
    			goto sand;
    		}
    		else
    		{
    			goto quant;
    		}
    	}
    	else if(cat==2)
    	{
    		clrscr();
    		getch();
    		fries:
    		gotoxy(24,3);textcolor(YELLOW);cprintf("************ FRENCH FRIES ************ ");
    		gotoxy(10,7);textcolor(YELLOW);cprintf("[1] Small French Fries                1.00");
    		gotoxy(10,8);textcolor(YELLOW);cprintf("[2] Medium French Fries               1.00");
    		gotoxy(10,9);textcolor(YELLOW);cprintf("[3] Large French Fries                1.00");
    		gotoxy(27,17);textcolor(YELLOW);cprintf("Meal Number: ");
    		gotoxy(43,17);textcolor(YELLOW);cscanf("%d", &f);
    		switch(f)
    		{
    			case 1:price=1.00;break;
    			case 2:price=2.00;break;
    			case 3:price=3.00;break;
    
    
    		}
    
    		if(f>3 || f<=0)
    		{
    			goto fries;
    		}
    		else
    		{
    			goto quant;
    		}
    	}
    	else if(cat==3)
    	{
    		clrscr();
    		getch();
    		salad:
    		gotoxy(26,3);textcolor(YELLOW);cprintf("************ SALADS *********** ");
    		gotoxy(10,7);textcolor(YELLOW);cprintf("[1] Veggie Salad                            1.00");
    		gotoxy(10,8);textcolor(YELLOW);cprintf("[2] Salad with Grilled Chicken              1.00");
    		gotoxy(10,9);textcolor(YELLOW);cprintf("[3] Salad with Crispy Chicken               1.00");
    		gotoxy(27,17);textcolor(YELLOW);cprintf("Meal Number:");
    		gotoxy(43,17);textcolor(YELLOW);cscanf("%d",&sal);
    		switch(sal)
    		{
    			case 1:price=1.00;break;
    			case 2:price=2.00;break;
    			case 3:price=3.00;break;
    
    		}
    
    		if(sal>3 || sal<=0)
    		{
    			goto salad;
    		}
    		else
    		{
    			goto quant;
    		}
    	}
    	else if(cat==4)
    	{
    		clrscr();
    		getch();
    		breakfast:
    		gotoxy(24,3);textcolor(YELLOW);cprintf("************ BREAKFAST ************");
    		gotoxy(10,7);textcolor(YELLOW);cprintf("[1] Egg Mcmuffin                       1.00");
    		gotoxy(10,8);textcolor(YELLOW);cprintf("[2] Sausage Mcmuffin                   1.00");
    		gotoxy(10,9);textcolor(YELLOW);cprintf("[3] Bacon, Egg & Cheese                1.00");
    		gotoxy(10,10);textcolor(YELLOW);cprintf("[4] Hotcakes                           1.00");
    		gotoxy(27,17);textcolor(YELLOW);cprintf("Meal Number:");
    		gotoxy(43,17);textcolor(YELLOW);cscanf("%d", &b);
    		switch(b)
    		{
    			case 1:price=1.00;break;
    			case 2:price=2.00;break;
    			case 3:price=3.00;break;
    			case 4:price=4.00;break;
    
    		}
    
    		if(b>4 || b<=0)
    		{
    			goto breakfast;
    		}
    		else
    		{
    			goto quant;
    		}
    
    	}
    	else if(cat==5)
    	{
    		clrscr();
    		getch();
    		dessert:
    		gotoxy(24,3);textcolor(YELLOW);cprintf("************ DESSERTS ************");
    		gotoxy(10,7);textcolor(YELLOW);cprintf("[1] Strawberry Sundae                1.00");
    		gotoxy(10,8);textcolor(YELLOW);cprintf("[2] Hot Caramel Sundae               1.00 ");
    		gotoxy(10,9);textcolor(YELLOW);cprintf("[3] Hot Fudge Sundae                 1.00");
    		gotoxy(10,10);textcolor(YELLOW);cprintf("[4] Vanilla IceCream                 1.00");
    		gotoxy(10,11);textcolor(YELLOW);cprintf("[5] Coke Float                       1.00");
    		gotoxy(27,17);textcolor(YELLOW);cprintf("Meal Number:");
    		gotoxy(43,17);textcolor(YELLOW);cscanf("%d", &d);
    		switch(d)
    		{
    			case 1:price=1.00;break;
    			case 2:price=2.00;break;
    			case 3:price=3.00;break;
    			case 4:price=4.00;break;
    			case 5:price=5.00;break;
    		}
    
    		if(d>5 || d<=0)
    		{
    			goto dessert;
    		}
    		else
    		{
    			goto quant;
    		}
    	}
    	else if(cat==6)
    	{
    		clrscr();
    		getch();
    		beverage:
    		gotoxy(24,3);textcolor(YELLOW);cprintf("************ BEVERAGES ************");
    		gotoxy(10,7);textcolor(YELLOW);cprintf("[1] Orange Juice(small)                  1.00");
    		gotoxy(10,8);textcolor(YELLOW);cprintf("[2] Orange Juice(medium)                 1.00");
    		gotoxy(10,9);textcolor(YELLOW);cprintf("[3] Orange Juice(large)                  1.00");
    		gotoxy(10,10);textcolor(YELLOW);cprintf("[4] Coca-Cola (small)                    1.00");
    		gotoxy(10,11);textcolor(YELLOW);cprintf("[5] Coca-Cola (medium)                   1.00");
    		gotoxy(10,12);textcolor(YELLOW);cprintf("[6] Coca-Cola (large)                    1.00");
    		gotoxy(10,13);textcolor(YELLOW);cprintf("[7] Ice tea(small)                       1.00");
    		gotoxy(10,14);textcolor(YELLOW);cprintf("[8] Ice tea(medium)                      1.00");
    		gotoxy(10,15);textcolor(YELLOW);cprintf("[9] Ice tea(large)                       1.00");
    		gotoxy(27,17);textcolor(YELLOW);cprintf("Meal Number:");
    		gotoxy(43,17);textcolor(YELLOW);cscanf("%d", &bev);
    		switch(bev)
    		{
    			case 1:price=1.00;break;
    			case 2:price=2.00;break;
    			case 3:price=3.00;break;
    			case 4:price=4.00;break;
    			case 5:price=5.00;break;
    			case 6:price=6.00;break;
    			case 7:price=7.00;break;
    			case 8:price=8.00;break;
    			case 9:price=9.00;break;
    		}
    
    		if(bev>9 || bev<=0)
    		{
    			goto beverage;
    		}
    		else
    		{
    			goto quant;
    		}
    	}
    
    		clrscr();
    		getch();
    		quant:
    		clrscr();
    		gotoxy(26,11);textcolor(YELLOW);cprintf(" How many? ");
    		gotoxy(40,11);textcolor(YELLOW);cscanf("%d", &quantity);
    
    		
    		other:
    		clrscr();
    		getch();
    		gotoxy(26,12);textcolor(YELLOW);cprintf(" Do u hav another order? [Y/N]");
    		gotoxy(26, 13);textcolor(YELLOW);cscanf("%c", &ans);
    		if(ans=='y' || ans=='Y')
    		{
    		                		clrscr();
    				goto category;
    		}
    		else if(ans=='n' || ans=='N')
    				goto sub;
    		else 
    				goto other;
    		sub:
    		clrscr();
    		subtotal=price * quantity;
    		vat=subtotal*0.12;
    
    		do
    		{
    			clrscr();
    			x=1;
    			gotoxy(31,2);textcolor(YELLOW);cprintf(" LOVE KO 'TO");
    		gotoxy(28,3);textcolor(YELLOW);cprintf("MCDONALD'S LIMKETKAI");
    		gotoxy(21,4);textcolor(YELLOW);cprintf("LAPASAN HIGHWAY, CAGAYAN DE ORO CITY");
    		gotoxy(19,5);textcolor(YELLOW);cprintf("OFFICIAL RECEIPT TIN-750-001-481-752  VAT");
    		gotoxy(18,7);textcolor(YELLOW);cprintf("MCDONALD'S LIMKETKAI TEL # 726637 / 8563693 ");
    		gotoxy(18,8);textcolor(YELLOW);cprintf("KS# 04      SERIAL NO. 97H04944T");
    		gotoxy(18,9);textcolor(YELLOW);cprintf("OFFICIAL RECEIPT NO.  04492114");
    		gotoxy(18,10);textcolor(YELLOW);cprintf("ORD#  2114 KS# 04      OCT.3'08 (FRI) 16:00");
    		
    		switch(s)
    		{
    			
    			case 1:gotoxy(17,12);textcolor(YELLOW);cprintf(" Hamburger            %d       1.00",quantity);break;
    			case 2:gotoxy(17,12);textcolor(YELLOW);cprintf(" Chessburger          %d       1.00",quantity);break;
    			case 3:gotoxy(17,12);textcolor(YELLOW);cprintf(" Double Chessburger       %d   1.00",quantity);break;
    			case 4:gotoxy(17,12);textcolor(YELLOW);cprintf(" Big Mac                 %d       1.00",quantity);break;
    			case 5:gotoxy(17,12);textcolor(YELLOW);cprintf("  Filet-O-Fish          %d      1.00",quantity);break;
    		}
    		switch(f)
    		{	
    			case 1:gotoxy(17,12);textcolor(YELLOW);cprintf(" Small French Fries         %d     1.00",quantity);break;
    			case 2:gotoxy(17,12);textcolor(YELLOW);cprintf(" Medium French Fries     %d        1.00",quantity);break;
    			case 3:gotoxy(17,12);textcolor(YELLOW);cprintf(" Large French Fries          %d    1.00",quantity);break;
    
    
    		}
    			switch(sal)
    		{	
    			case 1:gotoxy(17,12);textcolor(YELLOW);cprintf(" Veggie Salad          %d        1.00",quantity);break;
    			case 2:gotoxy(17,12);textcolor(YELLOW);cprintf(" Salad with Grilled Chicken       %d     1.00",quantity);break;
    			case 3:gotoxy(17,12);textcolor(YELLOW);cprintf(" Salad with Crispy Chicken        %d    1.00",quantity);break;
    
    		}
    			switch(b)
    		{	
    			case 1:gotoxy(17,12);textcolor(YELLOW);cprintf(" Egg Mcmuffin                   %d       1.00 ",quantity);break;
    			case 2:gotoxy(17,12);textcolor(YELLOW);cprintf(" Sausage Mcmuffin           %d        1.00 ",quantity);break;
    			case 3:gotoxy(17,12);textcolor(YELLOW);cprintf(" Bacon, Egg & Cheese    %d        1.00 ",quantity);break;
    			case 4:gotoxy(17,12);textcolor(YELLOW);cprintf(" Hotcakes                          %d  1.00 ",quantity);break;
    
    		}
    			switch(d)
    		{	
    			case 1:gotoxy(17,12);textcolor(YELLOW);cprintf(" Strawberry Sundae     %d       1.00",quantity);break;
    			case 2:gotoxy(17,12);textcolor(YELLOW);cprintf(" Hot Caramel Sundae  %d       1.00 ",quantity);break;
    			case 3:gotoxy(17,12);textcolor(YELLOW);cprintf(" Hot Fudge Sundae      %d       1.00",quantity);break;
    			case 4:gotoxy(17,12);textcolor(YELLOW);cprintf(" Vanilla IceCream         %d     1.00",quantity);break;
    			case 5:gotoxy(17,12);textcolor(YELLOW);cprintf(" Coke Float                   %d    1.00",quantity);break;
    		} 
    		switch(bev)
    		{	
    			case 1:gotoxy(17,12);textcolor(YELLOW);cprintf(" Orange Juice(small)          %d        1.00",quantity);break;
    			case 2:gotoxy(17,12);textcolor(YELLOW);cprintf(" Orange Juice(medium)     %d           1.00",quantity);break;
    			case 3:gotoxy(17,12);textcolor(YELLOW);cprintf(" Orange Juice(large)          %d       1.00 ",quantity);break;
    			case 4:gotoxy(17,12);textcolor(YELLOW);cprintf(" Coca-Cola (small)             %d        1.00",quantity);break;
    			case 5:gotoxy(17,12);textcolor(YELLOW);cprintf(" Coca-Cola (medium)        %d             1.00",quantity);break;
    			case 6:gotoxy(17,12);textcolor(YELLOW);cprintf(" Coca-Cola (large)             %d        1.00",quantity);break;
    			case 7:gotoxy(17,12);textcolor(YELLOW);cprintf(" Ice tea(small)                     %d      1.00",quantity);break;
    			case 8:gotoxy(17,12);textcolor(YELLOW);cprintf(" Ice tea(medium)                %d         1.00",quantity);break;
    			case 9:gotoxy(17,12);textcolor(YELLOW);cprintf(" Ice tea(large)                     %d     1.00",quantity);break;
    		}
    		gotoxy(44,15);textcolor(YELLOW);cprintf("TOTAL          %.2f",subtotal);
    		gotoxy(44,17);textcolor(YELLOW);cprintf("Cash Tend ");
    		gotoxy(59,17);textcolor(YELLOW);cscanf("%f",&cash);
    		if(cash>=subtotal)
    		{
    			change=cash-subtotal;
    			x=0;
    		}
    
    		}while(x==1);
    
    		clrscr();
    		getch();
    		gotoxy(31,2);textcolor(YELLOW);cprintf(" LOVE KO 'TO");
    		gotoxy(28,3);textcolor(YELLOW);cprintf("MCDONALD'S LIMKETKAI");
    		gotoxy(21,4);textcolor(YELLOW);cprintf("LAPASAN HIGHWAY, CAGAYAN DE ORO CITY");
    		gotoxy(19,5);textcolor(YELLOW);cprintf("OFFICIAL RECEIPT TIN-750-001-481-752  VAT");
    		gotoxy(18,7);textcolor(YELLOW);cprintf("MCDONALD'S LIMKETKAI TEL # 726637 / 8563693 ");
    		gotoxy(18,8);textcolor(YELLOW);cprintf("KS# 04      SERIAL NO. 97H04944T");
    		gotoxy(18,9);textcolor(YELLOW);cprintf("OFFICIAL RECEIPT NO.  04492114");
    		gotoxy(18,10);textcolor(YELLOW);cprintf("ORD#  2114 KS# 04      OCT.3'08 (FRI) 16:00");
    		
    			switch(s)
    		{
    			
    			case 1:gotoxy(17,12);textcolor(YELLOW);cprintf(" Hamburger            %d       1.00",quantity);break;
    			case 2:gotoxy(17,12);textcolor(YELLOW);cprintf(" Chessburger          %d       1.00",quantity);break;
    			case 3:gotoxy(17,12);textcolor(YELLOW);cprintf(" Double Chessburger       %d   1.00",quantity);break;
    			case 4:gotoxy(17,12);textcolor(YELLOW);cprintf(" Big Mac                 %d       1.00",quantity);break;
    			case 5:gotoxy(17,12);textcolor(YELLOW);cprintf("  Filet-O-Fish          %d      1.00",quantity);break;
    		}
    		switch(f)
    		{	
    			case 1:gotoxy(17,12);textcolor(YELLOW);cprintf(" Small French Fries         %d     1.00",quantity);break;
    			case 2:gotoxy(17,12);textcolor(YELLOW);cprintf(" Medium French Fries     %d        1.00",quantity);break;
    			case 3:gotoxy(17,12);textcolor(YELLOW);cprintf(" Large French Fries          %d    1.00",quantity);break;
    
    
    		}
    			switch(sal)
    		{	
    			case 1:gotoxy(17,12);textcolor(YELLOW);cprintf(" Veggie Salad          %d        1.00",quantity);break;
    			case 2:gotoxy(17,12);textcolor(YELLOW);cprintf(" Salad with Grilled Chicken       %d     1.00",quantity);break;
    			case 3:gotoxy(17,12);textcolor(YELLOW);cprintf(" Salad with Crispy Chicken        %d    1.00",quantity);break;
    
    		}
    			switch(b)
    		{	
    			case 1:gotoxy(17,12);textcolor(YELLOW);cprintf(" Egg Mcmuffin                   %d       1.00 ",quantity);break;
    			case 2:gotoxy(17,12);textcolor(YELLOW);cprintf(" Sausage Mcmuffin           %d        1.00 ",quantity);break;
    			case 3:gotoxy(17,12);textcolor(YELLOW);cprintf(" Bacon, Egg & Cheese    %d        1.00 ",quantity);break;
    			case 4:gotoxy(17,12);textcolor(YELLOW);cprintf(" Hotcakes                          %d  1.00 ",quantity);break;
    
    		}
    			switch(d)
    		{	
    			case 1:gotoxy(17,12);textcolor(YELLOW);cprintf(" Strawberry Sundae     %d       1.00",quantity);break;
    			case 2:gotoxy(17,12);textcolor(YELLOW);cprintf(" Hot Caramel Sundae  %d       1.00 ",quantity);break;
    			case 3:gotoxy(17,12);textcolor(YELLOW);cprintf(" Hot Fudge Sundae      %d       1.00",quantity);break;
    			case 4:gotoxy(17,12);textcolor(YELLOW);cprintf(" Vanilla IceCream         %d     1.00",quantity);break;
    			case 5:gotoxy(17,12);textcolor(YELLOW);cprintf(" Coke Float                   %d    1.00",quantity);break;
    		} 
    		switch(bev)
    		{	
    			case 1:gotoxy(17,12);textcolor(YELLOW);cprintf(" Orange Juice(small)          %d        1.00",quantity);break;
    			case 2:gotoxy(17,12);textcolor(YELLOW);cprintf(" Orange Juice(medium)     %d           1.00",quantity);break;
    			case 3:gotoxy(17,12);textcolor(YELLOW);cprintf(" Orange Juice(large)          %d       1.00 ",quantity);break;
    			case 4:gotoxy(17,12);textcolor(YELLOW);cprintf(" Coca-Cola (small)             %d        1.00",quantity);break;
    			case 5:gotoxy(17,12);textcolor(YELLOW);cprintf(" Coca-Cola (medium)        %d             1.00",quantity);break;
    			case 6:gotoxy(17,12);textcolor(YELLOW);cprintf(" Coca-Cola (large)             %d        1.00",quantity);break;
    			case 7:gotoxy(17,12);textcolor(YELLOW);cprintf(" Ice tea(small)                     %d      1.00",quantity);break;
    			case 8:gotoxy(17,12);textcolor(YELLOW);cprintf(" Ice tea(medium)                %d         1.00",quantity);break;
    			case 9:gotoxy(17,12);textcolor(YELLOW);cprintf(" Ice tea(large)                     %d     1.00",quantity);break;
    		}
    		gotoxy(44,15);textcolor(YELLOW);cprintf("TOTAL          %.2f",subtotal);
    		gotoxy(44,16);textcolor(YELLOW);cprintf("TAX INCLUDED   %.2f",vat);
    		gotoxy(44,17);textcolor(YELLOW);cprintf("CASH TEND     %.2f",cash);
    		gotoxy(44,18);textcolor(YELLOW);cprintf("CHANGE        %.2f",change);
    		gotoxy(26,20);textcolor(YELLOW);cprintf("THANK YOU! PLEASE COME AGAIN!");
    		gotoxy(23,21);textcolor(YELLOW);cprintf("THIS SERVES AS AN OFFICIAL RECEIPT");
    		gotoxy(27,22);textcolor(YELLOW);cprintf("FOR DELIVERIES,  PLEASE CALL ");
    		gotoxy(35,23);textcolor(YELLOW);cprintf("858-6236");
    
    		
    	getch();
    
    }
    
    ill understand if you'll scream by the time you saw my code T_T
    thanks......

  5. #5
    Registered User
    Join Date
    Sep 2008
    Posts
    5
    by the way does my
    Code:
    char or[]={};
    still needed??

    base on your replies your telling me
    to use strcpy to print the orders stored on my variable order
    am i right?? 0_o?

  6. #6
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Posts
    22,993
    Well... wow.
    You need to rework this code a little!
    First off, indentation is off in bits and pieces. What editor / IDE do you use?
    Second, you should have a read: http://cpwiki.sourceforge.net/Implicit_main
    And thirdly, as someone has already mentioned, you should get rid of all the gotos. Use different loops instead. You'll be surprised how much easier to read the code becomes!
    And those if / else if cat == N could be replaced with a switch.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  7. #7
    Woof, woof! zacs7's Avatar
    Join Date
    Mar 2007
    Location
    Australia
    Posts
    3,459
    There is no need to keep calling textcolor(YELLOW)

    Call it once, and then everytime you want to change the colour. And you haven't really used arrays or pointers at all, this could be about 1/5 of the size if you did. Don't you think it seems odd you learnt about them last week, but you haven't used them yet!?

  8. #8
    Registered User
    Join Date
    Sep 2008
    Posts
    5
    am im not really using any editor...i just write my code in a notepad an save it as a .c file ^^

    BTW thanks Elysia for the big help ^__^ it really enlighten me hehehe...

    oh i just would like to ask....

    in my program there are lots of choices and that choices are limited to let say from 1 to 5... so ive use an
    Code:
    if(cat>5 || cat<=0)
    but when i enter a letter it'll crash or go crazy
    what will i add or do so that it will not go crazy each time i enter
    something thatdont correspond to the chocies??

    please help me T__T
    thanks

  9. #9
    Registered User
    Join Date
    Sep 2008
    Location
    Toronto, Canada
    Posts
    1,832
    Your tests are fine.

    You should concentrate on cscanf("&#37;d", &cat); which may fail if you enter a letter. The value assigned to cat is, well, not assigned. So cat can be any garbage.

    cscan returns a number of arguments that were matched... You should check that and yell at the user if required.

  10. #10
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Posts
    22,993
    Quote Originally Posted by arjay View Post
    am im not really using any editor...i just write my code in a notepad an save it as a .c file ^^
    No, you shouldn't.
    That's what editors and IDEs are for.
    Notepad is the worst possible place to write code.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. In over my head
    By Shelnutt2 in forum C Programming
    Replies: 1
    Last Post: 07-08-2008, 07:54 PM
  2. Calling a Thread with a Function Pointer.
    By ScrollMaster in forum Windows Programming
    Replies: 6
    Last Post: 06-10-2006, 09:56 AM
  3. Game Pointer Trouble?
    By Drahcir in forum C Programming
    Replies: 8
    Last Post: 02-04-2006, 02:53 AM
  4. <Gulp>
    By kryptkat in forum Windows Programming
    Replies: 7
    Last Post: 01-14-2006, 01:03 PM
  5. Return Statement
    By Daveo in forum C Programming
    Replies: 21
    Last Post: 11-09-2004, 05:14 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21