find and remove error

//Write a program to move a mesage on the screen until a key ont he key board is hit?

#include <iostream.h>
#include <conio.h>
//#include <stdlib.h>

main()
{
int r=1;
clrscr();
while (!kbhit())
{
gotoxy(30,r);
cout<<"welcome\a";
gotoxy(30,r); //go to x cordinate of column , y cordinate of row
clreol(); //clear end of line
r++;
if(r==24) r=1;
}
getch();
//system("pause");
}
I dont really understand your question, what is the error message that you get?
just a tip it's easier to read your code if you place it in code tags like this

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#include <iostream.h>
#include <conio.h>
//#include <stdlib.h>

main()
{
int r=1;
clrscr();
while (!kbhit())
{
gotoxy(30,r);
cout<<"welcome\a";
gotoxy(30,r); //go to x cordinate of column , y cordinate of row
clreol(); //clear end of line
r++;
if(r==24) r=1;
}
getch();
//system("pause");
}
Last edited on
how i can active code tags in DEV software, and there are 4 errors compiler showing in the above code. please explain it. thanx

#include <iostream.h>
#include <conio.h>
#include <stdlib.h>

main()
{
int r=1;
clrscr();
while (!kbhit())
{
gotoxy(30,r);
cout<<"welcome\a";
gotoxy(30,r); //go to x cordinate of column , y cordinate of row
clreol(); //clear end of line
r++;
if(r==24) r=1;
}
getch();
//system("pause");
}
i have enable code tag but its not copied here..

Last edited on
:D nevermind, I don't see "gotoxy" defined anywhere in your code...

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#include <Windows.h>

typedef unsigned short ushort;

void gotoxy(ushort x, ushort y)
{
    HANDLE hStdOut = GetStdHandle(STD_OUTPUT_HANDLE);
    COORD Coord;
    Coord.X = x;
    Coord.Y = y;

    cout.flush();

    SetConsoleCurserPosition(hStdOut, Coord);
}


I'm not using Windows so not sure about Coord.X is short or unsigned short.

This is windows specific code, "conio.h" also is not a standard header.
Last edited on
@OP

Code tags are a formatting thing you use on this page, not elsewhere. Edit your post, then select your code, then press the <> button on the right on the format menu.

It would be easier if you post your compiler errors in full.
Sir here are the Error report of compiler:

1 C:\Dev-Cpp\include\c++\3.3.1\backward\iostream.h:31, from D:\C Programs\fun2.cpp In file included from C:/Dev-Cpp/include/c++/3.3.1/backward/iostream.h:31, from D:/C Programs/fun2.cpp

1 D:\C Programs\fun2.cpp from D:/C Programs/fun2.cpp

2 C:\Dev-Cpp\include\c++\3.3.1\backward\backward_warning.h:32 #warning This file includes at least one deprecated or antiquated header. Please consider using one of the 32 headers found in section 17.4.1.2 of the C++ standard. Examples include substituting the <X> header for the <X.h> header for C++ includes, or <sstream> instead of the deprecated header <strstream.h>. To disable this warning use -Wno-deprecated.

D:\C Programs\fun2.cpp In function `int main()':

8 D:\C Programs\fun2.cpp `clrscr' undeclared (first use this function)
(Each undeclared identifier is reported only once for each function it appears in.)

10 D:\C Programs\fun2.cpp `display' undeclared (first use this function)

D:\C Programs\fun2.cpp In function `void display()':

18 D:\C Programs\fun2.cpp `void display()' used prior to declaration
Topic archived. No new replies allowed.