Error:Declarartion terminated incorrect

Hello Everyone !
My name is raymond and I am new to this site
I do not have much knowledge of C++ system as in my school the do not teach so much would u be kind enough to point out what I did wrong in this program.
I use Borlands C++
I live in Kuwait and all my teacher have travelled,I try to get help from everywhere...Can anyone help me please to correct the errors please ?
I know this program is very primitive but it is to test the way of navigating with arrows..thanks alot



PROGRAM:-
#include<fstream.h> //for reading and writing files
#include<conio.h> //for clrscr()
#include<string.h> //for string characters
#include<stdio.h> //for gets and puts function
#include<process.h> //for exit function
#include<iomanip.h> //for setw function
#include<dos.h> //for delay and sleep function

void main()
{ char ch,c=0,che=16;
int i=1,j=16;

gotoxy(35,11);cout<<"MAIN MENU";
gotoxy(35,12);cout<<"___________";
gotoxy(13,16);cout<<"A.ADD";
gotoxy(13,18);cout<<"B.DISPLAYALL";
gotoxy(13,20);cout<<"C.DISPLAYINDIVIDUAL";
gotoxy(13,22);cout<<"D.DELETE";
gotoxy(52,16);cout<<"E.MODIFY";
gotoxy(52,18);cout<<"F.SALE";
gotoxy(52,20);cout<<"G.EXIT";
gotoxy(26,27);cout<<"USE ARROWS TO NAVIGATE";
gotoxy(i,j);cout<<che;
do
{ch=getch();
if(ch==72&&j-2>=16)
{gotoxy(i,j);cout<<c;j-2;gotoxy(i,j);cout<<che<<"\b";}
if(ch==75&&i-13>=13)
{gotoxy(i,j);cout<<c;i-=39;gotoxy(i,j);cout<<che<<"\b";}
if(ch==77&&i+39<=52)
{gotoxy(i,j);cout<<c;i+=39;gotoxy(i,j);cout<<che<<"\b";}
if(ch==80&&j+2<=22)
{gotoxy(i,j);cout<<c;j+=2;gotoxy(i,j);cout<<che<<"\b";}
}while(ch!=13);
cout<<"\a";
switch(ch)
{
case 13:
if(i==11&&j==16)
{
cout<<"ADDED";
cout<<"\a";
break;
}
else if(i==11&&j==18)
{
cout<<"DISPLAYEDALLMAN";
cout<<"\a";
break;
}
else if(i==11&&j==20)
{
cout<<"DISPLAYED INDIVIDUAL";
cout<<"\a";
break;
}
else if(i==11&&j==22)
{
cout<<"DELETED";
cout<<"\a";
break;
}
else if(i==50&&j==16)
{
cout<<cout<<"modified";
cout<<"\a";
break;
}
else if(i==50&&j==18)
{
cout<<"SOLD";
cout<<"\a";
break;
}
else if(i==50&&j==20)
{
cout<<"EXIT";
break;

}


}
}while(ch); //I get error here 'statement terminated incorrectly'and also

} //ERROR:unexpected }
1
2
3
}while(ch); //I get error here 'statement terminated incorrectly'and also <--- this is the end of main so while loop is outisde. Maybe you are missing a do somewhere above?

} //ERROR:unexpected } 


Also please use code tags. Select all your code and press the <> button or type [ code] before and [/code] after your code without the space though.
Last edited on
Okay Sir...I did it and now its working good beacause I I forgot to the 'do' for the while loop
but 1 more problem if u help me please sir......I ran this program and the arrow moves over to the place but when I press enter to select all it does is a beeping sound please help and does not cout anything BTW thank you so much in advance....if u can run the program u will understand





heres the program:-
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103


#include<fstream.h>    //for reading and writing files
#include<conio.h>      //for clrscr()
#include<string.h>     //for string characters
#include<stdio.h>      //for gets and puts function
#include<process.h>    //for exit function
#include<iomanip.h>    //for setw function
#include<dos.h>        //for delay and sleep function

class word
{
 int man;
 public:
 void add();
};
void word::add()
{
 cout<<"GOD IS GREAT";
};

void main()
{ char ch,c=0,che=16;
  int i=1,j=16;
  do
  {
  gotoxy(35,11);cout<<"MAIN MENU";
  gotoxy(35,12);cout<<"___________";
  gotoxy(13,16);cout<<"A.ADD";
  gotoxy(13,18);cout<<"B.DISPLAYALL";
  gotoxy(13,20);cout<<"C.DISPLAYINDIVIDUAL";
  gotoxy(13,22);cout<<"D.DELETE";
  gotoxy(52,16);cout<<"E.MODIFY";
  gotoxy(52,18);cout<<"F.SALE";
  gotoxy(52,20);cout<<"G.EXIT";
 gotoxy(26,27);cout<<"USE ARROWS TO NAVIGATE";
 gotoxy(i,j);cout<<che;
 do
 {ch=getch();
     if(ch==72&&j-2>=16)
 {gotoxy(i,j);cout<<c;j-=2;gotoxy(i,j);cout<<che<<"\b";}
 if(ch==75&&i-13>=13)
  {gotoxy(i,j);cout<<c;i-=39;gotoxy(i,j);cout<<che<<"\b";}
 if(ch==77&&i+39<=52)
  {gotoxy(i,j);cout<<c;i+=39;gotoxy(i,j);cout<<che<<"\b";}
 if(ch==80&&j+2<=22)
  {gotoxy(i,j);cout<<c;j+=2;gotoxy(i,j);cout<<che<<"\b";}
 }while(ch!=13);
 cout<<"\a";
 switch(ch)
     {
 case 13:
       if(i==11&&j==16)
       {
         clrscr();
        void add();
        cout<<"ADDED";
        cout<<"\a\a\a\a\a\a\a\a\a\a";
        break;
       }
       else if(i==11&&j==18)
       {
        cout<<"DISPLAYEDALLMAN";
        cout<<"\a\a";
        break;
       }
       else if(i==11&&j==20)
       {
        cout<<"DISPLAYED INDIVIDUAL";
        cout<<"\a";
        break;
       }
       else if(i==11&&j==22)
       {
        cout<<"DELETED";
        cout<<"\a";
        break;
       }
       else if(i==50&&j==16)
       {
        cout<<cout<<"modified";
        cout<<"\a";
        break;
       }
       else if(i==50&&j==18)
       {
        cout<<"SOLD";
        cout<<"\a";
        break;
       }
       else if(i==50&&j==20)
       {
        cout<<"EXIT";
        break;

       }

      }
       }while(ch);
 }


Last edited on
Well, '\a' is for "alert" aka a beep.
but along with '\a' I have also put a cout statement 'SOLD','ADD',etc but nothing seems to be printed on the screen all I hear is beep sound :'( Idk what to do.......BTW thanks a lot sir


please reply sir

p.s.forgive me for bad english and ignorance of imprtance of C++
Last edited on
Maybe they are being printed at arbitrary locations since you are using goto. Also you are using non-standard and c libraries instead of the c++ ones. main should return int and you are forgetting to include iostream and you never tell the compiler that many things are part of the std:: namespace.
Thank U sir may U live a hundred years...your right it could be at random locations
Topic archived. No new replies allowed.