#include%26lt;stdio.h%26gt;
#include%26lt;stdlib.h%26gt;
#include%26lt;conio.h%26gt;
int num, x[100], y=0;
int a=0, b=0, c=0;
char choice, z;
void main()
{
clrscr();
printf("How many storage? ");
scanf("%i",%26amp;a);
clrscr();
jed:
printf("\t\t\t\tSTACK MENU\n\n");
printf("\t\t=========================...
printf("\t\t [A] Push Stack\n");
printf("\t\t [B] Pop Stack\n");
printf("\t\t [C] Delete all data\n");
printf("\t\t [D] Display Stack Content\n");
printf("\t\t [E] Exit program\n");
printf("\t\t=========================...
printf("\t\t\tPlease enter a selection%26gt;%26gt; ");
scanf("%s",%26amp;choice);
if (tolower(choice)=='a')
{
margie:
if (b%26gt;=a)
{
printf("Unable to input data..\n\n");
printf("The storage is full\n");
goto jed;
}
clrscr();
printf("Enter data(numbers only): \n\n");
scanf("%i",%26amp;x[b]);
b++;
printf("You want to add data?[Y/N] ");
scanf("%s",%26amp;x);
y++;
if (tolower(x)=='y')
{
goto margie;
}
else if (tolower(x)=='n')
{
goto jed;
}
}
if(tolower(choice)=='b'){
PopData();
printf("\nPress any key to continue.");
getch();
clrscr();
goto jed;
}
if(tolower(choice)=='d'){
ViewData();
printf("\nPress any key to continue.");
getch();
clrscr();
goto jed;
}
clrscr();
goto jed;
}
/* This is where the error shows */
if(tolower(choice)=='e'){
{
printf("Thank you for using my program");
exit(0);
}
}
{
PopData()
}
if (b==0)
{
clrscr();
printf("Storage is Empty!\n");
}
else
{
clrscr();
b--;
printf("The previous added data was deleted!");
delay (1000);
}
PopDataall()
{
if (b==0)
}
{
clrscr();
}
printf("Storage is Empty!\n");
{
else
{
clrscr();
b=0;
printf("All data was deleted!");
delay (1000);
}
}
/* Until here */
ViewData()
{
int n;
clrscr();
if(b==0) {
printf("Storage is Empty!");
}
else
{
for(n=(b-1); n%26gt;=0; n--) {
printf("%i\n", x[n]);
}
}
}
I'm having this "decalaration syntax error", the part where the error is marked by /* */. please help!
I'm not 100% sure, but I suspect the } on the line above the /* */ is either out of place or unneeded.
Also, try to forget about the goto. You can always get the same results with the structured statements for, while, if..else. and switch. In this case in particular, a
switch ( tolower(choice) )
{
case 'a':....
break;
case 'b': ....
break;
etc.
}
would probably avoid all the goto ject's.
Hope that helps.
Reply:You could try.. If it is only one line like that, putting
//my comment
instead of
/*my comment*/
using /* is usually to put multiple lines of comments.
If that doesn't work, try putting the //
after the line of code above it, and if you would prefer, a /*
send flowers
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment