The c program is an example and should be correct.
I tried to compile the c file with MS studio 6.0. But failed with the
several err and warning messages. Does anyone know how to make it work?
Thanks.
Here is the c file:
/*file name way.c*/
#include <stdio.h>
#include <conio.h>
#include <dos.h>
void put (int x,int y) {
textcolor(CYAN);
gotoxy(x,y);
cprintf(".");
sound(440);
delay(3);
nosound();
}
void snd (void){ // it was just an idea ;)
sound(100);
delay(2);
nosound();
}
void main()
{
int x=1,y=2,ctr=0;
_setcursortype(_NOCURSOR); //just for eye comfort ;)
clrscr();
gotoxy(1,1);
textcolor(WHITE);
cprintf("ESC to exit, use arrowkeys to control"); //directive
window(1,2,80,25); // setting moving area
put(x,y); // puting smiling face
while(ctr!=1)
switch(getch()){
//you can use kbhit here but i wrote just ex.
case 77: // write
if(x>=1 && x<79){
gotoxy(x,y);
cprintf(" ");
x++;
}
put(x,y);
snd();
break;
case 75: // left
if(x>1 && x<=80){
gotoxy(x,y);
cprintf(" ");
x--;
}
put(x,y);
snd();
break;
case 72: // up
if(y<=25 && y>2){
gotoxy(x,y);
cprintf(" ");
y--;
}
put(x,y);
snd();
break;
case 80: // down
if (y<24 && y>=2){
gotoxy(x,y);
cprintf(" ");
y++;
}
put(x,y);
snd();
break;
case 27: // quit
ctr=1;
break;
}
textcolor(7); //turn back to normal color
return(0);
} 12 1587
kim <yj******@hotmail.com> writes: The c program is an example and should be correct.
I tried to compile the c file with MS studio 6.0. But failed with the several err and warning messages. Does anyone know how to make it work? Thanks.
You didn't show us the error and warning messages.
Here is the c file: /*file name way.c*/ #include <stdio.h> #include <conio.h> #include <dos.h>
<conio.h> and <dos.h> are non-standard headers. We can't help you
here with an problems you might be having with them; you'll need to
ask in a Windows-specific newsgroup.
[snip] void main()
main() returns int, not void. Some compilers may accept void main(),
but there's really no reason at all not to declare it properly:
int main(void)
[snip] return(0); }
You're returning a value from a void function. If it were a function
other than main(), you might either drop the return statement or
change it to "return;". But since you should declare main to return
int anyway, that should fix any problem with the return statement.
Any other problems you're having are likely to be Windows specific; if
so, we can't help you with them.
--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
kim wrote: The c program is an example and should be correct.
I tried to compile the c file with MS studio 6.0. But failed with the several err and warning messages. Does anyone know how to make it work? Thanks.
Start by replaincing the illegal and illiterate return type for main.
The take out all the non-standard stuff (or ask about your program in a
Microsoft-specific newsgroup, mailing list, or tech support). That
means removing lines containing <conio.h>, <dos.h>, textcolor(),
gotoxy(), cprintf(), sound(), delay(), nosound(), _setcursortype(),
clrscr(), window(), and getch(). The remaining code is below. It now
has a broken switch statement.
You might also fix those magic numbers.
#include <stdio.h>
void put (int x,int y) { }
void snd (void){ }
int main(void)
{
int x=1,y=2,ctr=0;
put(x,y);
while(ctr!=1)
switch( /* need a variable here */){
case 77:
if(x>=1 && x<79) x++;
put(x,y);
snd();
break;
case 75:
if(x>1 && x<=80) x--;
break;
case 72:
if(y<=25 && y>2) y--;
break;
case 80:
if (y<24 && y>=2) y++;
break;
case 27:
ctr=1;
break;
}
return 0;
}
[OP's code] /*file name way.c*/ #include <stdio.h> #include <conio.h> #include <dos.h> void put (int x,int y) { textcolor(CYAN); gotoxy(x,y); cprintf("."); sound(440); delay(3); nosound();
}
void snd (void){ // it was just an idea ;) sound(100); delay(2); nosound(); }
void main() { int x=1,y=2,ctr=0; _setcursortype(_NOCURSOR); //just for eye comfort ;) clrscr(); gotoxy(1,1); textcolor(WHITE); cprintf("ESC to exit, use arrowkeys to control"); //directive window(1,2,80,25); // setting moving area put(x,y); // puting smiling face while(ctr!=1) switch(getch()){ //you can use kbhit here but i wrote just ex. case 77: // write if(x>=1 && x<79){ gotoxy(x,y); cprintf(" "); x++; } put(x,y); snd(); break; case 75: // left if(x>1 && x<=80){ gotoxy(x,y); cprintf(" "); x--; } put(x,y); snd(); break; case 72: // up if(y<=25 && y>2){ gotoxy(x,y); cprintf(" "); y--; } put(x,y); snd(); break; case 80: // down if (y<24 && y>=2){ gotoxy(x,y); cprintf(" "); y++; } put(x,y); snd(); break; case 27: // quit ctr=1; break; } textcolor(7); //turn back to normal color return(0); }
On Wed, 14 Jul 2004 17:20:11 -0500, kim <yj******@hotmail.com> wrote: The c program is an example and should be correct.
I tried to compile the c file with MS studio 6.0. But failed with the several err and warning messages. Does anyone know how to make it work?
If the program were correct, it would compile. Did you attempt to
resolve the messages.
Thanks.
Here is the c file: /*file name way.c*/ #include <stdio.h> #include <conio.h> #include <dos.h> void put (int x,int y) { textcolor(CYAN);
Where is textcolor declared? Where is CYAN declared?
gotoxy(x,y);
Where is gotoxy declared?
cprintf(".");
Ditto many times
snip
<<Remove the del for email>>
>The c program is an example and should be correct.
All of the functions you call here are non-standard functions,
except for the ones you define. main returns int, not void.
<conio.h> and <dos.h> are nonstandard include files. I tried to compile the c file with MS studio 6.0. But failed with the several err and warning messages. Does anyone know how to make it work?
Quote those error messages. Do any of them have anything to do
with "Norton Antivirus"?
Gordon L. Burditt
On Wed, 14 Jul 2004 17:20:11 -0500, kim wrote: The c program is an example and should be correct.
I tried to compile the c file with MS studio 6.0. But failed with the several err and warning messages. Does anyone know how to make it work? Thanks.
I'm very sure those error messages will actually be very helpful.
Read them, fix them.
Functions you used are not availabele in MS studio header files.
conio.h and dos.h
You can use TC compilers to work it okay.
saroj
kim wrote: The c program is an example and should be correct.
I tried to compile the c file with MS studio 6.0. But failed with the several err and warning messages. Does anyone know how to make it work? Thanks.
Here is the c file: /*file name way.c*/ #include <stdio.h> #include <conio.h> #include <dos.h> void put (int x,int y) { textcolor(CYAN); gotoxy(x,y); cprintf("."); sound(440); delay(3); nosound();
}
void snd (void){ // it was just an idea ;) sound(100); delay(2); nosound(); }
void main() { int x=1,y=2,ctr=0; _setcursortype(_NOCURSOR); //just for eye comfort ;) clrscr(); gotoxy(1,1); textcolor(WHITE); cprintf("ESC to exit, use arrowkeys to control"); //directive window(1,2,80,25); // setting moving area put(x,y); // puting smiling face while(ctr!=1) switch(getch()){ //you can use kbhit here but i wrote just ex. case 77: // write if(x>=1 && x<79){ gotoxy(x,y); cprintf(" "); x++; } put(x,y); snd(); break; case 75: // left if(x>1 && x<=80){ gotoxy(x,y); cprintf(" "); x--; } put(x,y); snd(); break; case 72: // up if(y<=25 && y>2){ gotoxy(x,y); cprintf(" "); y--; } put(x,y); snd(); break; case 80: // down if (y<24 && y>=2){ gotoxy(x,y); cprintf(" "); y++; } put(x,y); snd(); break; case 27: // quit ctr=1; break; } textcolor(7); //turn back to normal color return(0); }
In <cd**********@216.39.134.18> Barry Schwarz <sc******@deloz.net> writes: On Wed, 14 Jul 2004 17:20:11 -0500, kim <yj******@hotmail.com> wrote:
The c program is an example and should be correct.
I tried to compile the c file with MS studio 6.0. But failed with the several err and warning messages. Does anyone know how to make it work?
If the program were correct, it would compile. Did you attempt to resolve the messages.
Here is the c file: /*file name way.c*/ #include <stdio.h> #include <conio.h> #include <dos.h> void put (int x,int y) { textcolor(CYAN);
Where is textcolor declared? Where is CYAN declared?
gotoxy(x,y);
Where is gotoxy declared?
In <conio.h>, most likely, which is included. cprintf(".");
Ditto many times
Ditto.
If you want to complain about non-standard functions, then do so, rather
than asking irrelevant (to the OP) questions.
Dan
--
Dan Pop
DESY Zeuthen, RZ group
Email: Da*****@ifh.de
In <ln************@nuthaus.mib.org> Keith Thompson <ks***@mib.org> writes: <conio.h> and <dos.h> are non-standard headers. We can't help you here with an problems you might be having with them; you'll need to ask in a Windows-specific newsgroup.
Well, they aren't Windows headers, either, so there is no point in
redirecting to a Windows-specific newsgroup. Especially as long as
a newsgroup dedicated to MSDOS programming still exists.
Dan
--
Dan Pop
DESY Zeuthen, RZ group
Email: Da*****@ifh.de Da*****@cern.ch (Dan Pop) writes: In <ln************@nuthaus.mib.org> Keith Thompson <ks***@mib.org> writes:<conio.h> and <dos.h> are non-standard headers. We can't help you here with an problems you might be having with them; you'll need to ask in a Windows-specific newsgroup.
Well, they aren't Windows headers, either, so there is no point in redirecting to a Windows-specific newsgroup. Especially as long as a newsgroup dedicated to MSDOS programming still exists.
Good point (it's comp.os.msdos.programmer).
--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
On 15 Jul 2004 13:11:30 GMT, Da*****@cern.ch (Dan Pop) wrote: In <cd**********@216.39.134.18> Barry Schwarz <sc******@deloz.net> writes:
On Wed, 14 Jul 2004 17:20:11 -0500, kim <yj******@hotmail.com> wrote:
The c program is an example and should be correct.
I tried to compile the c file with MS studio 6.0. But failed with the several err and warning messages. Does anyone know how to make it work? If the program were correct, it would compile. Did you attempt to resolve the messages.
Here is the c file: /*file name way.c*/ #include <stdio.h> #include <conio.h> #include <dos.h> void put (int x,int y) { textcolor(CYAN);
Where is textcolor declared? Where is CYAN declared?
gotoxy(x,y);
Where is gotoxy declared?
In <conio.h>, most likely, which is included.
Since I compiled the OP's code exactly as written using the same
compiler he specified and since I received 21 diagnostics about
undefined functions and undefined identifiers, including the few I
mentioned, I am pretty certain that your assumption is incorrect. cprintf(".");
Ditto many times
Ditto.
If you want to complain about non-standard functions, then do so, rather than asking irrelevant (to the OP) questions.
It must be wonderful to know what was relevant to the OP without even
checking the few facts available.
I'm sorry my pedagogical technique of requiring analysis rather than
spoon feeding the answer doesn't meet with your approval.
<<Remove the del for email>>
In <cd**********@216.39.143.4> Barry Schwarz <sc******@deloz.net> writes: On 15 Jul 2004 13:11:30 GMT, Da*****@cern.ch (Dan Pop) wrote:
In <cd**********@216.39.134.18> Barry Schwarz <sc******@deloz.net> writes:
On Wed, 14 Jul 2004 17:20:11 -0500, kim <yj******@hotmail.com> wrote:
The c program is an example and should be correct.
I tried to compile the c file with MS studio 6.0. But failed with the several err and warning messages. Does anyone know how to make it work?
If the program were correct, it would compile. Did you attempt to resolve the messages.
Here is the c file: /*file name way.c*/ #include <stdio.h> #include <conio.h> #include <dos.h> void put (int x,int y) { textcolor(CYAN);
Where is textcolor declared? Where is CYAN declared?
gotoxy(x,y);
Where is gotoxy declared?
In <conio.h>, most likely, which is included.
Since I compiled the OP's code exactly as written using the same compiler he specified and since I received 21 diagnostics about undefined functions and undefined identifiers, including the few I mentioned, I am pretty certain that your assumption is incorrect.
Nope, it ain't. You're simply not using the implementation for which
the code was written (most likely, some TURBO C compiler). Apparently,
neither did the OP.
Dan
--
Dan Pop
DESY Zeuthen, RZ group
Email: Da*****@ifh.de This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Chris |
last post by:
Hi,
I am trying to use the data access dll in one of my projects and was
originally getting the error:
'Microsoft.Practices.EnterpriseLibrary.Data' does not have a strong
name.
I then...
|
by: genestarwing |
last post by:
QUESTION:
Write a program that opens and read a text file and records how many
times each word occurs in the file. Use a binary search tree modified
to store both a word and the number of times it...
|
by: dasilva109 |
last post by:
Hi guys
I am new to C++ and need urgent help with this part of my code for a
uni coursework I have to submit by Thursday
//ClientData.h
#ifndef CLIENTDATA_H
#define CLIENTDATA_H
#include...
|
by: dasilva109 |
last post by:
Hi guys
I am new to C++ and need urgent help with this part of my code for a
uni coursework I have to submit by Thursday
//ClientData.h
#ifndef CLIENTDATA_H
#define CLIENTDATA_H
#include...
|
by: frame |
last post by:
Hi,
The other day, I was experimenting with Predicates and STL and came
across a gotcha with the following program. The objective of the
program is to remove those strings, from a vector of...
|
by: AppleBag |
last post by:
I'm having the worst time trying to login to myspace through code. Can
someone tell me how to do this? Please try it yourself before replying,
only because I have asked this a couple of times in...
|
by: Dew |
last post by:
Hello, iam new to programming, and ive been given a task in my Uni to complete certain exercises but i found it very difficulty to solve them. I was wandering if there is someone who can help me...
|
by: sasimca007 |
last post by:
Hello friends,
I installed java with the following command:
sudo apt-get update
synaptic...
|
by: hcaptech |
last post by:
This is my Test.can you help me ?
1.Which of the following statement about C# varialble is incorrect ?
A.A variable is a computer memory location identified by a unique name
B.A variable's name...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
| |