I have so many programs that are originally written in Turbo C++ IDE, but when i try to run them in Dev C++ then they do not compile successfully. Wonder whats the solution and why they generate errors? Take for example the following program:
// program to control a line of sign
// control the cursor
//
#include<conio.h>
#include<stdio.h>
#include<process.h>
void main()
{
char ch,
*menu[]={"first ","second","third ","fourth","fifth "},
*first[]={"one","0001"},
*second[]={"two","0002"},
*third[]={"three","0003"},
*fourth[]={"four","0004"};
int i,cur=0;
clrscr();
textcolor(3);
for(i=0;i<=4;i++)
{
gotoxy(8+13*i,3);
cprintf("%s",menu[i]);
}
_setcursortype(0);
while(1)
{
ch=getch();
switch(ch)
{
case 77:
textcolor(3);
textbackground(0);
gotoxy(8+13*cur,3);
cprintf("%s",menu[cur]);
if(cur==4)
cur=0;
else
cur++;
textcolor(0);
textbackground(3);
gotoxy(8+13*cur,3);
cprintf("%s",menu[cur]);
break;
case 75:
textcolor(3);
textbackground(0);
gotoxy(8+13*cur,3);
cprintf("%s",menu[cur]);
if(cur==0)
cur=4;
else
cur--;
textcolor(0);
textbackground(3);
gotoxy(8+13*cur,3);
cprintf("%s",menu[cur]);
break;
case 72:
break;
case 27:
exit(1);
}
}
}
Please help
Tags: