473,394 Members | 1,781 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Snake Game problem

I have written a snake game. There are 2 levels in the game(I
finished 1st level). It can run in VC++ without problem but, when I
run it on the dev C++ 4.9.9.2, it cannot run. I want to practice my
programming in Dev C++ rather than in VC++. What can I do now?

The Game:
--- writing a snake game using color console window.
1-player game. The player makes use of 4 arrow keys to operate the
movement
to chase and eat as much food (#) as possible. Food with a different
color has
score. The game will end when the snake hits itself or the player hits
ESC key.
-----Use link list is a must.

Thanks!
Jun 27 '08 #1
19 4368
On Jun 10, 9:50 am, "foolsmart2...@gmail.com"
<foolsmart2...@gmail.comwrote:
I have written a snake game. There are 2 levels in the game(I
finished 1st level). It can run in VC++ without problem but, when I
run it on the dev C++ 4.9.9.2, it cannot run. I want to practice my
programming in Dev C++ rather than in VC++. What can I do now?

The Game:
--- writing a snake game using color console window.
1-player game. The player makes use of 4 arrow keys to operate the
movement
to chase and eat as much food (#) as possible. Food with a different
color has
score. The game will end when the snake hits itself or the player hits
ESC key.
-----Use link list is a must.

Thanks!
You need to post more info regarding the compilation options and the
error messages you got when you tried to compile in Dev C++, to be of
more help.

Shan
Jun 27 '08 #2
sh*******@yahoo.com wrote:
On Jun 10, 9:50 am, "foolsmart2...@gmail.com"
<foolsmart2...@gmail.comwrote:
>I have written a snake game. There are 2 levels in the game(I
finished 1st level). It can run in VC++ without problem but, when I
run it on the dev C++ 4.9.9.2, it cannot run. I want to practice my
programming in Dev C++ rather than in VC++. What can I do now?

The Game:
--- writing a snake game using color console window.
1-player game. The player makes use of 4 arrow keys to operate the
movement
to chase and eat as much food (#) as possible. Food with a different
color has
score. The game will end when the snake hits itself or the player hits
ESC key.
-----Use link list is a must.

Thanks!

You need to post more info regarding the compilation options and the
error messages you got when you tried to compile in Dev C++, to be of
more help.
Also, the OP should post that additional info in a forum where it is
topical. Compilation options of particular compilers and the quirks of
platform specific libraries or tricks (needed for color console windows, of
which standard C++ would not know anything) do not belong here.
Best

Kai-Uwe Bux
Jun 27 '08 #3
On Jun 10, 12:50*pm, "foolsmart2...@gmail.com"
<foolsmart2...@gmail.comwrote:
I have written a snake game. *There are 2 levels in the game(I
finished 1st level). * It can run in VC++ without problem but, when I
run it on the dev C++ 4.9.9.2, it cannot run. * *I want to practice my
programming in Dev C++ rather than in VC++. What can I do now?

The Game:
--- writing a snake game using color console window.
1-player game. The player makes use of 4 arrow keys to operate the
movement
to chase and eat as much food (#) as possible. Food with a different
color has
score. The game will end when the snake hits itself or the player hits
ESC key.
-----Use link list is a must.

Thanks!
Owing to the file is quite a lot of code, I think I will use another
method to tell you the error. But now, I suffer a problem in Dev C++,
here is the code:
#include<iostream>
#include<iomanip>
#include<string>
using namespace std;

struct CarType{
string maker;
int year;
float price;
}

void getYourCar(CarType & car);
int main()
{
CarType myCar, yourCar;

myCar.make = "Mercedes";
myCar.year = 2008;
myCar.price = 556653;

getYourCar(yourCar);

cout << "Your car is a: " << yourCar.maker << endl;
cout << fixed << showpoint << setprecision(2) <<
"I will offer $" << yourCar.price -100 << "for your car."
<<endl;

system("pause");
return 0;

}

void getYourCar(CarType & car)
{
cout << "Enter your maker: ";
cin >car.maker;
cout << "Enter the year: ";
cin >car.year;
cout << "Enter the price:$";
cin >car.price;
}

Error messages are gotten.

Compiler: Default compiler
Executing g++.exe...
g++.exe "C:\Documents and Settings\Desktop\structtest.cpp" -o "C:
\Documents and Settings\Desktop\structtest.exe" -I"C:\Dev-Cpp\lib
\gcc\mingw32\3.4.2\include" -I"C:\Dev-Cpp\include\c++
\3.4.2\backward" -I"C:\Dev-Cpp\include\c++\3.4.2\mingw32" -I"C:\Dev-
Cpp\include\c++\3.4.2" -I"C:\Dev-Cpp\include" -L"C:\Dev-Cpp\lib"
C:\Documents and Settings\Desktop\structtest.cpp:12: error: new types
may not be defined in a return type
C:\Documents and Settings\Desktop\structtest.cpp:12: error: two or
more data types in declaration of `getYourCar'

C:\Documents and Settings\Desktop\structtest.cpp: In function `int
main()':
C:\Documents and Settings\Desktop\structtest.cpp:19: error: 'struct
CarType' has no member named 'make'

C:\Documents and Settings\Desktop\structtest.cpp: In function `void
getYourCar(CarType&)':
C:\Documents and Settings\Desktop\structtest.cpp:35: error: new
declaration `void getYourCar(CarType&)'
C:\Documents and Settings\Desktop\structtest.cpp:12: error: ambiguates
old declaration `CarType getYourCar(CarType&)'

Execution terminated

This code should be no problem, why it still cannot run in Dev C++?
Jun 27 '08 #4
These is no ';' after your struct CarType definition. Does it cause
your problem?
And try to use 'void getYourCar(struct CarType & car);' instead?

On Jun 10, 7:06*pm, "foolsmart2...@gmail.com"
<foolsmart2...@gmail.comwrote:
On Jun 10, 12:50*pm, "foolsmart2...@gmail.com"

<foolsmart2...@gmail.comwrote:
I have written a snake game. *There are 2 levels in the game(I
finished 1st level). * It can run in VC++ without problem but, when I
run it on the dev C++ 4.9.9.2, it cannot run. * *I want to practice my
programming in Dev C++ rather than in VC++. What can I do now?
The Game:
--- writing a snake game using color console window.
1-player game. The player makes use of 4 arrow keys to operate the
movement
to chase and eat as much food (#) as possible. Food with a different
color has
score. The game will end when the snake hits itself or the player hits
ESC key.
-----Use link list is a must.
Thanks!

Owing to the file is quite a lot of code, I think I will use another
method to tell you the error. *But now, I suffer a problem in Dev C++,
here is the code:
#include<iostream>
#include<iomanip>
#include<string>
using namespace std;

struct CarType{
* * * *string maker;
* * * *int year;
* * * *float price;

}

*void getYourCar(CarType & car);

int main()
{
* * CarType myCar, yourCar;

* * myCar.make = "Mercedes";
* * myCar.year = 2008;
* * myCar.price = 556653;

* * getYourCar(yourCar);

* * cout << "Your car is a: " << yourCar.maker << endl;
* * cout << fixed << showpoint << setprecision(2) <<
* * * * *"I will offer $" << yourCar.price -100 << "for your car.."
<<endl;

* * system("pause");
* * return 0;

}

void getYourCar(CarType & car)
{
* * *cout << "Enter your maker: ";
* * *cin >car.maker;
* * *cout << "Enter the year: ";
* * *cin >car.year;
* * *cout << "Enter the price:$";
* * *cin >car.price;
*}

Error messages are gotten.

Compiler: Default compiler
Executing *g++.exe...
g++.exe "C:\Documents and Settings\Desktop\structtest.cpp" -o "C:
\Documents and Settings\Desktop\structtest.exe" * *-I"C:\Dev-Cpp\lib
\gcc\mingw32\3.4.2\include" *-I"C:\Dev-Cpp\include\c++
\3.4.2\backward" *-I"C:\Dev-Cpp\include\c++\3.4.2\mingw32" *-I"C:\Dev-
Cpp\include\c++\3.4.2" *-I"C:\Dev-Cpp\include" * -L"C:\Dev-Cpp\lib"
C:\Documents and Settings\Desktop\structtest.cpp:12: error: new types
may not be defined in a return type
C:\Documents and Settings\Desktop\structtest.cpp:12: error: two or
more data types in declaration of `getYourCar'

C:\Documents and Settings\Desktop\structtest.cpp: In function `int
main()':
C:\Documents and Settings\Desktop\structtest.cpp:19: error: 'struct
CarType' has no member named 'make'

C:\Documents and Settings\Desktop\structtest.cpp: In function `void
getYourCar(CarType&)':
C:\Documents and Settings\Desktop\structtest.cpp:35: error: new
declaration `void getYourCar(CarType&)'
C:\Documents and Settings\Desktop\structtest.cpp:12: error: ambiguates
old declaration `CarType getYourCar(CarType&)'

Execution terminated

This code should be no problem, why it still cannot run in Dev C++?
Jun 27 '08 #5
On Jun 10, 7:24 pm, Linlin Yan <yanlinli...@gmail.comwrote:
These is no ';' after your struct CarType definition. Does it cause
your problem?
And try to use 'void getYourCar(struct CarType & car);' instead?

On Jun 10, 7:06 pm, "foolsmart2...@gmail.com"

<foolsmart2...@gmail.comwrote:
On Jun 10, 12:50 pm, "foolsmart2...@gmail.com"
<foolsmart2...@gmail.comwrote:
I have written a snake game. There are 2 levels in the game(I
finished 1st level). It can run in VC++ without problem but, when I
run it on the dev C++ 4.9.9.2, it cannot run. I want to practice my
programming in Dev C++ rather than in VC++. What can I do now?
The Game:
--- writing a snake game using color console window.
1-player game. The player makes use of 4 arrow keys to operate the
movement
to chase and eat as much food (#) as possible. Food with a different
color has
score. The game will end when the snake hits itself or the player hits
ESC key.
-----Use link list is a must.
Thanks!
Owing to the file is quite a lot of code, I think I will use another
method to tell you the error. But now, I suffer a problem in Dev C++,
here is the code:
#include<iostream>
#include<iomanip>
#include<string>
using namespace std;
struct CarType{
string maker;
int year;
float price;
}
void getYourCar(CarType & car);
int main()
{
CarType myCar, yourCar;
myCar.make = "Mercedes";
myCar.year = 2008;
myCar.price = 556653;
getYourCar(yourCar);
cout << "Your car is a: " << yourCar.maker << endl;
cout << fixed << showpoint << setprecision(2) <<
"I will offer $" << yourCar.price -100 << "for your car."
<<endl;
system("pause");
return 0;
}
void getYourCar(CarType & car)
{
cout << "Enter your maker: ";
cin >car.maker;
cout << "Enter the year: ";
cin >car.year;
cout << "Enter the price:$";
cin >car.price;
}
Error messages are gotten.
Compiler: Default compiler
Executing g++.exe...
g++.exe "C:\Documents and Settings\Desktop\structtest.cpp" -o "C:
\Documents and Settings\Desktop\structtest.exe" -I"C:\Dev-Cpp\lib
\gcc\mingw32\3.4.2\include" -I"C:\Dev-Cpp\include\c++
\3.4.2\backward" -I"C:\Dev-Cpp\include\c++\3.4.2\mingw32" -I"C:\Dev-
Cpp\include\c++\3.4.2" -I"C:\Dev-Cpp\include" -L"C:\Dev-Cpp\lib"
C:\Documents and Settings\Desktop\structtest.cpp:12: error: new types
may not be defined in a return type
C:\Documents and Settings\Desktop\structtest.cpp:12: error: two or
more data types in declaration of `getYourCar'
C:\Documents and Settings\Desktop\structtest.cpp: In function `int
main()':
C:\Documents and Settings\Desktop\structtest.cpp:19: error: 'struct
CarType' has no member named 'make'
C:\Documents and Settings\Desktop\structtest.cpp: In function `void
getYourCar(CarType&)':
C:\Documents and Settings\Desktop\structtest.cpp:35: error: new
declaration `void getYourCar(CarType&)'
C:\Documents and Settings\Desktop\structtest.cpp:12: error: ambiguates
old declaration `CarType getYourCar(CarType&)'
Execution terminated
This code should be no problem, why it still cannot run in Dev C++?
Oh, you are right, it is my careless mistake.
Now , the following is my snake game's error:
Compiler: Default compiler
Building Makefile: "E:\Dev C++\CityU\Snake\Makefile.win"
Executing make...
make.exe -f "E:\Dev C++\CityU\Snake\Makefile.win" all
g++.exe -D__DEBUG__ -c main.cpp -o main.o -I"C:/Dev-Cpp/lib/gcc/
mingw32/3.4.2/include" -I"C:/Dev-Cpp/include/c++/3.4.2/backward" -
I"C:/Dev-Cpp/include/c++/3.4.2/mingw32" -I"C:/Dev-Cpp/include/c++/
3.4.2" -I"C:/Dev-Cpp/include" -g3

In file included from SnakeList.h:5,
from FoodList.h:10,
from main.cpp:13:

SnakeNode.h:19:7: warning: extra tokens at end of #endif directive

g++.exe -D__DEBUG__ FoodList.o FoodNode.o main.o SnakeList.o
SnakeNode.o -o "Snake.exe" -L"C:/Dev-Cpp/lib" colorScreen.a timer.a -
g3

Execution terminated
Compilation successful

-----------here is SnakeList.h------------------
#ifndef _SNAKE_LIST_
#define _SNAKE_LIST_

#include "colorScreen.h"
#include "SnakeNode.h"
#include "FoodList.h"

class SnakeList
{
public:
SnakeList(ColorScreen& g);
SnakeList();
~SnakeList();

void adds (ColorScreen g, int x,int y,char in) ;
//void adds (ColorScreen g,int x,int y,char in) ;
void display(const SnakeNode* ptr,ColorScreen g,int sx,int sy,char
in) ;
void display(ColorScreen g,int sx, int sy,char in) ;

// function to search X hits body;
bool search(SnakeNode* ptr);
bool search();

void move(ColorScreen g,int x,int y, char in);
void move(SnakeNode*& ptr,ColorScreen g, int x,int y, char in);

void clear(SnakeNode*& ptr,ColorScreen g, int sx,int sy);
void clear(ColorScreen g,int sx,int sy);
int length (const SnakeNode* ptr) const;
int length() const;
private:

ColorScreen sGame;
int maxlen,size;
SnakeNode *head;

};
#endif
---------------------------------------

What is wrong?
Jun 27 '08 #6
<fo***********@gmail.comwrote:
The Game:
--- writing a snake game using color console window.
1-player game. The player makes use of 4 arrow keys to operate the
movement
to chase and eat as much food (#) as possible. Food with a different
color has
score. The game will end when the snake hits itself or the player
hits
ESC key.
There are several things in there that make this a non-standard program:
The use of color, the use of the arrow keys, and the fact that ESC need not
be followed by <Enter>. The topic cops inhibit answers to questions such as
this. There is a brand new froup devoted to solving this problem, it is
comp.lang.c++.misc. Try posting your question there and we will see if the
cure seems to work.
Jun 27 '08 #7
On Tue, 10 Jun 2008 08:37:37 -0700, osmium wrote:
not be followed by <Enter>. The topic cops inhibit answers to questions
such as this. There is a brand new froup devoted to solving this
problem, it is comp.lang.c++.misc. Try posting your question there and
we will see if the cure seems to work.
Um... does comp.lang.c++.misc actually exist (yet) and if so, where? It
doesn't show up on my news server or, so far as I can make out, on Google
Groups.

--
Lionel B
Jun 27 '08 #8
"Lionel B" wrote:
On Tue, 10 Jun 2008 08:37:37 -0700, osmium wrote:
>not be followed by <Enter>. The topic cops inhibit answers to questions
such as this. There is a brand new froup devoted to solving this
problem, it is comp.lang.c++.misc. Try posting your question there and
we will see if the cure seems to work.

Um... does comp.lang.c++.misc actually exist (yet) and if so, where? It
doesn't show up on my news server or, so far as I can make out, on Google
Groups.
It was made available on individual.net yesterday. The only message so far
is an announcement (history, raison d'etre, etc) by a guy with a name I
didn't recognize. I think the new froup is a Real Good Thing, abandon this
group to the language lawyers and the green eyeshade set. Then they will
have this one and the std one and the moderated one for their "mine is
bigger than yours" talk and their endless fascination with minutiae.
Jun 27 '08 #9
fo***********@gmail.com wrote:
>
SnakeNode.h:19:7: warning: extra tokens at end of #endif directive
[snip]
What is wrong?
The compiler told you what and where exactly is it wrong.
Jun 27 '08 #10
On Jun 10, 9:51*pm, "foolsmart2...@gmail.com"
<foolsmart2...@gmail.comwrote:
On Jun 10, 7:24 pm, Linlin Yan <yanlinli...@gmail.comwrote:
These is no ';' after your struct CarType definition. Does it cause
your problem?
And try to use 'void getYourCar(struct CarType & car);' instead?
On Jun 10, 7:06 pm, "foolsmart2...@gmail.com"
<foolsmart2...@gmail.comwrote:
On Jun 10, 12:50 pm, "foolsmart2...@gmail.com"
<foolsmart2...@gmail.comwrote:
I have written a snake game. *There are 2 levels in the game(I
finished 1st level). * It can run in VC++ without problem but, when I
run it on the dev C++ 4.9.9.2, it cannot run. * *I want to practice my
programming in Dev C++ rather than in VC++. What can I do now?
The Game:
--- writing a snake game using color console window.
1-player game. The player makes use of 4 arrow keys to operate the
movement
to chase and eat as much food (#) as possible. Food with a different
color has
score. The game will end when the snake hits itself or the player hits
ESC key.
-----Use link list is a must.
Thanks!
Owing to the file is quite a lot of code, I think I will use another
method to tell you the error. *But now, I suffer a problem in Dev C++,
here is the code:
#include<iostream>
#include<iomanip>
#include<string>
using namespace std;
struct CarType{
* * * *string maker;
* * * *int year;
* * * *float price;
}
*void getYourCar(CarType & car);
int main()
{
* * CarType myCar, yourCar;
* * myCar.make = "Mercedes";
* * myCar.year = 2008;
* * myCar.price = 556653;
* * getYourCar(yourCar);
* * cout << "Your car is a: " << yourCar.maker << endl;
* * cout << fixed << showpoint << setprecision(2) <<
* * * * *"I will offer $" << yourCar.price -100 << "for yourcar."
<<endl;
* * system("pause");
* * return 0;
}
void getYourCar(CarType & car)
{
* * *cout << "Enter your maker: ";
* * *cin >car.maker;
* * *cout << "Enter the year: ";
* * *cin >car.year;
* * *cout << "Enter the price:$";
* * *cin >car.price;
*}
Error messages are gotten.
Compiler: Default compiler
Executing *g++.exe...
g++.exe "C:\Documents and Settings\Desktop\structtest.cpp" -o "C:
\Documents and Settings\Desktop\structtest.exe" * *-I"C:\Dev-Cpp\lib
\gcc\mingw32\3.4.2\include" *-I"C:\Dev-Cpp\include\c++
\3.4.2\backward" *-I"C:\Dev-Cpp\include\c++\3.4.2\mingw32" *-I"C:\Dev-
Cpp\include\c++\3.4.2" *-I"C:\Dev-Cpp\include" * -L"C:\Dev-Cpp\lib"
C:\Documents and Settings\Desktop\structtest.cpp:12: error: new types
may not be defined in a return type
C:\Documents and Settings\Desktop\structtest.cpp:12: error: two or
more data types in declaration of `getYourCar'
C:\Documents and Settings\Desktop\structtest.cpp: In function `int
main()':
C:\Documents and Settings\Desktop\structtest.cpp:19: error: 'struct
CarType' has no member named 'make'
C:\Documents and Settings\Desktop\structtest.cpp: In function `void
getYourCar(CarType&)':
C:\Documents and Settings\Desktop\structtest.cpp:35: error: new
declaration `void getYourCar(CarType&)'
C:\Documents and Settings\Desktop\structtest.cpp:12: error: ambiguates
old declaration `CarType getYourCar(CarType&)'
Execution terminated
This code should be no problem, why it still cannot run in Dev C++?

Oh, you are right, it is my careless mistake.
Now , the following is my snake game's error:
Compiler: Default compiler
Building Makefile: "E:\Dev C++\CityU\Snake\Makefile.win"
Executing *make...
make.exe -f "E:\Dev C++\CityU\Snake\Makefile.win" all
g++.exe -D__DEBUG__ -c main.cpp -o main.o -I"C:/Dev-Cpp/lib/gcc/
mingw32/3.4.2/include" *-I"C:/Dev-Cpp/include/c++/3.4.2/backward" *-
I"C:/Dev-Cpp/include/c++/3.4.2/mingw32" *-I"C:/Dev-Cpp/include/c++/
3.4.2" *-I"C:/Dev-Cpp/include" * *-g3

In file included from SnakeList.h:5,
* * * * * * * * *from FoodList.h:10,
* * * * * * * * *from main.cpp:13:

SnakeNode.h:19:7: warning: extra tokens at end of #endif directive

g++.exe -D__DEBUG__ FoodList.o FoodNode.o main.o SnakeList.o
SnakeNode.o *-o "Snake.exe" -L"C:/Dev-Cpp/lib" colorScreen.a timer.a *-
g3

Execution terminated
Compilation successful
Since here it said 'successful', why did you still ask about wrongs?
Maybe some functions you used are not standard. So the program can not
run as you think. I think you can debug into your code, and try to
find standard way to implement them.
>
-----------here is SnakeList.h------------------
#ifndef _SNAKE_LIST_
#define _SNAKE_LIST_

#include "colorScreen.h"
#include "SnakeNode.h"
#include "FoodList.h"

class SnakeList
{
public:
* * * * SnakeList(ColorScreen& g);
* * * * SnakeList();
* * * * ~SnakeList();

* * * * void adds (ColorScreen g, int x,int y,char in) ;
* * * * //void adds (ColorScreen g,int x,int y,char in) ;

* * * * void display(const SnakeNode* ptr,ColorScreen g,int sx,intsy,char
in) ;
* * * * void display(ColorScreen g,int sx, int sy,char in) ;

* * * * // function to search X hits body;
* * * * bool search(SnakeNode* ptr);
* * * * bool search();

* * * * void move(ColorScreen g,int x,int y, char in);
* * * * void move(SnakeNode*& ptr,ColorScreen g, int x,int y, charin);

* * * * void clear(SnakeNode*& ptr,ColorScreen g, int sx,int sy);
* * * * void clear(ColorScreen g,int sx,int sy);

* * * * int length (const SnakeNode* ptr) const;
* * * * int length() const;

private:

* * * * ColorScreen sGame;
* * * * int maxlen,size;
* * * * SnakeNode **head;

};

#endif
---------------------------------------

What is wrong?
Jun 27 '08 #11
osmium wrote:
"Lionel B" wrote:
Um... does comp.lang.c++.misc actually exist (yet) and if so,
where? It doesn't show up on my news server or, so far as I can
make out, on Google Groups.

It was made available on individual.net yesterday. The only message
so far is an announcement (history, raison d'etre, etc) by a guy with
a name I didn't recognize.
Did it actually go through the usual discussion and voting process? I
don't recall anything about it.


Brian
Jun 27 '08 #12
"Default User" wrote:
osmium wrote:
>"Lionel B" wrote:
Um... does comp.lang.c++.misc actually exist (yet) and if so,
where? It doesn't show up on my news server or, so far as I can
make out, on Google Groups.

It was made available on individual.net yesterday. The only message
so far is an announcement (history, raison d'etre, etc) by a guy with
a name I didn't recognize.

Did it actually go through the usual discussion and voting process? I
don't recall anything about it.
I didn't follow what was going on, I knew that someone - or group - was
unhappy with the way things were and was trying to do something about it,
but I didn't help. I feel that 99.9999999999999% of what goes on in the
world is beyond my control. There is still only one post on the newsgroup.
Here is it in it's entirety, posted by Gary L. Burnore. As I said earlier,
individual.net picked it up yesterday - Monday.

---- snip ----
The Last Call for Comments on 12 May 2008 initiated a five-day period
for final comments. Following this comment period, the Big-8
Management Board has decided by consensus to create the newsgroup
comp.lang.c++.misc.

For your newsgroups file:
comp.lang.c++.misc Development in C++, libraries, cross and
single targets

comp.lang.c++.misc is an unmoderated newsgroup which will serve as a
forum for discussing C++ related issues not a part of the language
standard. This includes development, libraries and single-platform or
cross-platform C++ programming techniques. Topics that may be
discussed
include:

- Idiom for archiving specific tasks.
- Discussion of portability issues in C++.
- Inquiries as to whether a particular library exists, or a list
of suitable libraries for a given task.
- Discussions of whether a particular library is any good, or if
it should be avoided in favor of a different library.
- Cross-platform programming techniques in general.
- Particular libraries, how to work with them and how they
work internally.

Posting of advertising and/or promotional material of any kind to
comp.lang.c++.misc is explicitly prohibited. Posting of binaries is
not permitted, with the exception of small binary components in
otherwise non-binary postings, such as PGP signatures or X-Face
headers. Posts must be readable as plain text. HTML, RTF and
similarly formatted messages are prohibited.

Jun 27 '08 #13
On Jun 11, 1:53*am, Linlin Yan <yanlinli...@gmail.comwrote:
On Jun 10, 9:51*pm, "foolsmart2...@gmail.com"

<foolsmart2...@gmail.comwrote:
On Jun 10, 7:24 pm, Linlin Yan <yanlinli...@gmail.comwrote:
These is no ';' after your struct CarType definition. Does it cause
your problem?
And try to use 'void getYourCar(struct CarType & car);' instead?
On Jun 10, 7:06 pm, "foolsmart2...@gmail.com"
<foolsmart2...@gmail.comwrote:
On Jun 10, 12:50 pm, "foolsmart2...@gmail.com"
<foolsmart2...@gmail.comwrote:
I have written a snake game. *There are 2 levels in the game(I
finished 1st level). * It can run in VC++ without problem but, when I
run it on the dev C++ 4.9.9.2, it cannot run. * *I want to practice my
programming in Dev C++ rather than in VC++. What can I do now?
The Game:
--- writing a snake game using color console window.
1-player game. The player makes use of 4 arrow keys to operate the
movement
to chase and eat as much food (#) as possible. Food with a different
color has
score. The game will end when the snake hits itself or the player hits
ESC key.
-----Use link list is a must.
Thanks!
Owing to the file is quite a lot of code, I think I will use another
method to tell you the error. *But now, I suffer a problem in Dev C++,
here is the code:
#include<iostream>
#include<iomanip>
#include<string>
using namespace std;
struct CarType{
* * * *string maker;
* * * *int year;
* * * *float price;
}
*void getYourCar(CarType & car);
int main()
{
* * CarType myCar, yourCar;
* * myCar.make = "Mercedes";
* * myCar.year = 2008;
* * myCar.price = 556653;
* * getYourCar(yourCar);
* * cout << "Your car is a: " << yourCar.maker << endl;
* * cout << fixed << showpoint << setprecision(2) <<
* * * * *"I will offer $" << yourCar.price -100 << "for your car."
<<endl;
* * system("pause");
* * return 0;
}
void getYourCar(CarType & car)
{
* * *cout << "Enter your maker: ";
* * *cin >car.maker;
* * *cout << "Enter the year: ";
* * *cin >car.year;
* * *cout << "Enter the price:$";
* * *cin >car.price;
*}
Error messages are gotten.
Compiler: Default compiler
Executing *g++.exe...
g++.exe "C:\Documents and Settings\Desktop\structtest.cpp" -o "C:
\Documents and Settings\Desktop\structtest.exe" * *-I"C:\Dev-Cpp\lib
\gcc\mingw32\3.4.2\include" *-I"C:\Dev-Cpp\include\c++
\3.4.2\backward" *-I"C:\Dev-Cpp\include\c++\3.4.2\mingw32" *-I"C:\Dev-
Cpp\include\c++\3.4.2" *-I"C:\Dev-Cpp\include" * -L"C:\Dev-Cpp\lib"
C:\Documents and Settings\Desktop\structtest.cpp:12: error: new types
may not be defined in a return type
C:\Documents and Settings\Desktop\structtest.cpp:12: error: two or
more data types in declaration of `getYourCar'
C:\Documents and Settings\Desktop\structtest.cpp: In function `int
main()':
C:\Documents and Settings\Desktop\structtest.cpp:19: error: 'struct
CarType' has no member named 'make'
C:\Documents and Settings\Desktop\structtest.cpp: In function `void
getYourCar(CarType&)':
C:\Documents and Settings\Desktop\structtest.cpp:35: error: new
declaration `void getYourCar(CarType&)'
C:\Documents and Settings\Desktop\structtest.cpp:12: error: ambiguates
old declaration `CarType getYourCar(CarType&)'
Execution terminated
This code should be no problem, why it still cannot run in Dev C++?
Oh, you are right, it is my careless mistake.
Now , the following is my snake game's error:
Compiler: Default compiler
Building Makefile: "E:\Dev C++\CityU\Snake\Makefile.win"
Executing *make...
make.exe -f "E:\Dev C++\CityU\Snake\Makefile.win" all
g++.exe -D__DEBUG__ -c main.cpp -o main.o -I"C:/Dev-Cpp/lib/gcc/
mingw32/3.4.2/include" *-I"C:/Dev-Cpp/include/c++/3.4.2/backward" *-
I"C:/Dev-Cpp/include/c++/3.4.2/mingw32" *-I"C:/Dev-Cpp/include/c++/
3.4.2" *-I"C:/Dev-Cpp/include" * *-g3
In file included from SnakeList.h:5,
* * * * * * * * *from FoodList.h:10,
* * * * * * * * *from main.cpp:13:
SnakeNode.h:19:7: warning: extra tokens at end of #endif directive
g++.exe -D__DEBUG__ FoodList.o FoodNode.o main.o SnakeList.o
SnakeNode.o *-o "Snake.exe" -L"C:/Dev-Cpp/lib" colorScreen.a timer.a *-
g3
Execution terminated
Compilation successful

Since here it said 'successful', why did you still ask about wrongs?
Maybe some functions you used are not standard. So the program can not
run as you think. I think you can debug into your code, and try to
find standard way to implement them.


-----------here is SnakeList.h------------------
#ifndef _SNAKE_LIST_
#define _SNAKE_LIST_
#include "colorScreen.h"
#include "SnakeNode.h"
#include "FoodList.h"
class SnakeList
{
public:
* * * * SnakeList(ColorScreen& g);
* * * * SnakeList();
* * * * ~SnakeList();
* * * * void adds (ColorScreen g, int x,int y,char in) ;
* * * * //void adds (ColorScreen g,int x,int y,char in) ;
* * * * void display(const SnakeNode* ptr,ColorScreen g,int sx,int sy,char
in) ;
* * * * void display(ColorScreen g,int sx, int sy,char in) ;
* * * * // function to search X hits body;
* * * * bool search(SnakeNode* ptr);
* * * * bool search();
* * * * void move(ColorScreen g,int x,int y, char in);
* * * * void move(SnakeNode*& ptr,ColorScreen g, int x,int y, char in);
* * * * void clear(SnakeNode*& ptr,ColorScreen g, int sx,int sy);
* * * * void clear(ColorScreen g,int sx,int sy);
* * * * int length (const SnakeNode* ptr) const;
* * * * int length() const;
private:
* * * * ColorScreen sGame;
* * * * int maxlen,size;
* * * * SnakeNode **head;
};
#endif
---------------------------------------
What is wrong?- Hide quoted text -

- Show quoted text -- Hide quoted text -

- Show quoted text -
Actually, it runs with a cmd-like board without anything. But in VC+
+, there are pictures and I can play it but in dev C++, it cannot!
Jun 27 '08 #14
On Jun 11, 11:56*am, "foolsmart2...@gmail.com"
<foolsmart2...@gmail.comwrote:
On Jun 11, 1:53*am, Linlin Yan <yanlinli...@gmail.comwrote:
On Jun 10, 9:51*pm, "foolsmart2...@gmail.com"
<foolsmart2...@gmail.comwrote:
On Jun 10, 7:24 pm, Linlin Yan <yanlinli...@gmail.comwrote:
These is no ';' after your struct CarType definition. Does it cause
your problem?
And try to use 'void getYourCar(struct CarType & car);' instead?
On Jun 10, 7:06 pm, "foolsmart2...@gmail.com"
<foolsmart2...@gmail.comwrote:
On Jun 10, 12:50 pm, "foolsmart2...@gmail.com"
<foolsmart2...@gmail.comwrote:
I have written a snake game. *There are 2 levels in the game(I
finished 1st level). * It can run in VC++ without problem but,when I
run it on the dev C++ 4.9.9.2, it cannot run. * *I want to practice my
programming in Dev C++ rather than in VC++. What can I do now?
The Game:
--- writing a snake game using color console window.
1-player game. The player makes use of 4 arrow keys to operate the
movement
to chase and eat as much food (#) as possible. Food with a different
color has
score. The game will end when the snake hits itself or the player hits
ESC key.
-----Use link list is a must.
Thanks!
Owing to the file is quite a lot of code, I think I will use another
method to tell you the error. *But now, I suffer a problem in Dev C++,
here is the code:
#include<iostream>
#include<iomanip>
#include<string>
using namespace std;
struct CarType{
* * * *string maker;
* * * *int year;
* * * *float price;
}
*void getYourCar(CarType & car);
int main()
{
* * CarType myCar, yourCar;
* * myCar.make = "Mercedes";
* * myCar.year = 2008;
* * myCar.price = 556653;
* * getYourCar(yourCar);
* * cout << "Your car is a: " << yourCar.maker << endl;
* * cout << fixed << showpoint << setprecision(2) <<
* * * * *"I will offer $" << yourCar.price -100 << "for your car."
<<endl;
* * system("pause");
* * return 0;
}
void getYourCar(CarType & car)
{
* * *cout << "Enter your maker: ";
* * *cin >car.maker;
* * *cout << "Enter the year: ";
* * *cin >car.year;
* * *cout << "Enter the price:$";
* * *cin >car.price;
*}
Error messages are gotten.
Compiler: Default compiler
Executing *g++.exe...
g++.exe "C:\Documents and Settings\Desktop\structtest.cpp" -o "C:
\Documents and Settings\Desktop\structtest.exe" * *-I"C:\Dev-Cpp\lib
\gcc\mingw32\3.4.2\include" *-I"C:\Dev-Cpp\include\c++
\3.4.2\backward" *-I"C:\Dev-Cpp\include\c++\3.4.2\mingw32" *-I"C:\Dev-
Cpp\include\c++\3.4.2" *-I"C:\Dev-Cpp\include" * -L"C:\Dev-Cpp\lib"
C:\Documents and Settings\Desktop\structtest.cpp:12: error: new types
may not be defined in a return type
C:\Documents and Settings\Desktop\structtest.cpp:12: error: two or
more data types in declaration of `getYourCar'
C:\Documents and Settings\Desktop\structtest.cpp: In function `int
main()':
C:\Documents and Settings\Desktop\structtest.cpp:19: error: 'struct
CarType' has no member named 'make'
C:\Documents and Settings\Desktop\structtest.cpp: In function `void
getYourCar(CarType&)':
C:\Documents and Settings\Desktop\structtest.cpp:35: error: new
declaration `void getYourCar(CarType&)'
C:\Documents and Settings\Desktop\structtest.cpp:12: error: ambiguates
old declaration `CarType getYourCar(CarType&)'
Execution terminated
This code should be no problem, why it still cannot run in Dev C++?
Oh, you are right, it is my careless mistake.
Now , the following is my snake game's error:
Compiler: Default compiler
Building Makefile: "E:\Dev C++\CityU\Snake\Makefile.win"
Executing *make...
make.exe -f "E:\Dev C++\CityU\Snake\Makefile.win" all
g++.exe -D__DEBUG__ -c main.cpp -o main.o -I"C:/Dev-Cpp/lib/gcc/
mingw32/3.4.2/include" *-I"C:/Dev-Cpp/include/c++/3.4.2/backward" *-
I"C:/Dev-Cpp/include/c++/3.4.2/mingw32" *-I"C:/Dev-Cpp/include/c++/
3.4.2" *-I"C:/Dev-Cpp/include" * *-g3
In file included from SnakeList.h:5,
* * * * * * * * *from FoodList.h:10,
* * * * * * * * *from main.cpp:13:
SnakeNode.h:19:7: warning: extra tokens at end of #endif directive
g++.exe -D__DEBUG__ FoodList.o FoodNode.o main.o SnakeList.o
SnakeNode.o *-o "Snake.exe" -L"C:/Dev-Cpp/lib" colorScreen.a timer.a*-
g3
Execution terminated
Compilation successful
Since here it said 'successful', why did you still ask about wrongs?
Maybe some functions you used are not standard. So the program can not
run as you think. I think you can debug into your code, and try to
find standard way to implement them.
-----------here is SnakeList.h------------------
#ifndef _SNAKE_LIST_
#define _SNAKE_LIST_
#include "colorScreen.h"
#include "SnakeNode.h"
#include "FoodList.h"
class SnakeList
{
public:
* * * * SnakeList(ColorScreen& g);
* * * * SnakeList();
* * * * ~SnakeList();
* * * * void adds (ColorScreen g, int x,int y,char in) ;
* * * * //void adds (ColorScreen g,int x,int y,char in) ;
* * * * void display(const SnakeNode* ptr,ColorScreen g,int sx,int sy,char
in) ;
* * * * void display(ColorScreen g,int sx, int sy,char in) ;
* * * * // function to search X hits body;
* * * * bool search(SnakeNode* ptr);
* * * * bool search();
* * * * void move(ColorScreen g,int x,int y, char in);
* * * * void move(SnakeNode*& ptr,ColorScreen g, int x,int y, char in);
* * * * void clear(SnakeNode*& ptr,ColorScreen g, int sx,int sy);
* * * * void clear(ColorScreen g,int sx,int sy);
* * * * int length (const SnakeNode* ptr) const;
* * * * int length() const;
private:
* * * * ColorScreen sGame;
* * * * int maxlen,size;
* * * * SnakeNode **head;
};
#endif
---------------------------------------
What is wrong?- Hide quoted text -
- Show quoted text -- Hide quoted text -
- Show quoted text -

Actually, it runs with a cmd-like board without anything. *But in VC+
+, there are pictures and I can play it but in dev C++, it cannot!
Since you use 'int main()' as main function, the application is
compiled as a console one, which opens the cmd window. Windows
application's main function must be WinMain(). I think you need to
check the compiling and linking options.
Jun 27 '08 #15
On 10 jun, 23:52, "Default User" <defaultuse...@yahoo.comwrote:
osmium wrote:
"Lionel B" wrote:
Um... does comp.lang.c++.misc actually exist (yet) and if so,
where? It doesn't show up on my news server or, so far as I can
make out, on Google Groups.
It was made available on individual.net yesterday. The only message
so far is an announcement (history, raison d'etre, etc) by a guy with
a name I didn't recognize.

Did it actually go through the usual discussion and voting process? I
don't recall anything about it.
I also don't recall seeing any votes, but it seems genuine.
At least, I can find a reference to the group in the (moderated)
groups news.groups.proposals and news.announce.newsgroups.
Now, we just have to see how many servers will start carrying the new
group.
>
Brian
Bart v Ingen Schenau
Jun 27 '08 #16
On Jun 10, 12:50 pm, "foolsmart2...@gmail.com"
<foolsmart2...@gmail.comwrote:
I have written a snake game. There are 2 levels in the game(I
finished 1st level). It can run in VC++ without problem but, when I
run it on the dev C++ 4.9.9.2, it cannot run. I want to practice my
programming in Dev C++ rather than in VC++. What can I do now?

The Game:
--- writing a snake game using color console window.
1-player game. The player makes use of 4 arrow keys to operate the
movement
to chase and eat as much food (#) as possible. Food with a different
color has
score. The game will end when the snake hits itself or the player hits
ESC key.
-----Use link list is a must.

Thanks!
Finally,the problem has been solved. Thanks everyone.
Jun 27 '08 #17
osmium wrote:
"Default User" wrote:
Did it actually go through the usual discussion and voting process?
I don't recall anything about it.
---- snip ----
The Last Call for Comments on 12 May 2008 initiated a five-day period
for final comments. Following this comment period, the Big-8
Management Board has decided by consensus to create the newsgroup
comp.lang.c++.misc.
Ok, I guess it did. I don't recall it here (a logical spot) but it
seems to have gone through the process.

It sounds like a useless group to me, but I could be wrong.

Brian
Jun 27 '08 #18
Bart van Ingen Schenau wrote:
On 10 jun, 23:52, "Default User" <defaultuse...@yahoo.comwrote:
osmium wrote:
"Lionel B" wrote:
Um... does comp.lang.c++.misc actually exist
Did it actually go through the usual discussion and voting process?
I don't recall anything about it.

I also don't recall seeing any votes, but it seems genuine.
At least, I can find a reference to the group in the (moderated)
groups news.groups.proposals and news.announce.newsgroups.
Now, we just have to see how many servers will start carrying the new
group.
Voting should go through the main group when creating a splinter, but
that's the Big Six's problem. Maybe it was referenced here and I missed
it.


Brian
Jun 27 '08 #19
On Tue, 10 Jun 2008 09:46:24 -0700, osmium wrote:
"Lionel B" wrote:
>On Tue, 10 Jun 2008 08:37:37 -0700, osmium wrote:
>>not be followed by <Enter>. The topic cops inhibit answers to
questions such as this. There is a brand new froup devoted to solving
this problem, it is comp.lang.c++.misc. Try posting your question
there and we will see if the cure seems to work.

Um... does comp.lang.c++.misc actually exist (yet) and if so, where? It
doesn't show up on my news server or, so far as I can make out, on
Google Groups.

It was made available on individual.net yesterday. The only message so
far is an announcement (history, raison d'etre, etc) by a guy with a
name I didn't recognize. I think the new froup is a Real Good Thing,
Maybe, maybe not. Have to see whether it takes off and is actually useful
to anyone.
abandon this group to the language lawyers and the green eyeshade set.
Um... this ng exists specifically to discuss C++ *language* issues. As I
understand it the whole idea of this new group was to create a forum to
discuss non-language-specific issues which nonetheless pertain to C++. If
it does take off - and thereby reduces the (substantial) noise of non-
language issues raised in this ng - then as far as I'm concerned that'll
be a Real Good Thing. Whether that will happen remains to be seen.

As I see it, most of the OT posts here relate to platform/compiler/
library/... issues, which generally have their *own* forums anyway; so
I'm a bit sceptical as to what purpose the new group serves. But we'll
have to wait and see.
Then they will have this one and the std one and the moderated one for
their "mine is bigger than yours" talk
Actually, I think the new ng would be an excellent forum for the willy-
waver contingent. Please let them all go there, now ;-)
and their endless fascination with minutiae.
Well, sometimes the minutiae bites... C++ is like that.

--
Lionel B
Jun 27 '08 #20

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

21
by: BlackHawke | last post by:
My name is Nick Soutter, I own a small game development company (www.aepoxgames.net) making our first game (www.andromedaonline.net) in java. I am writing because we are having a very...
138
by: theodp | last post by:
--> From http://www.techdirt.com/articles/20040406/1349225.shtml Microsoft Patents Saving The Name Of A Game Contributed by Mike on Tuesday, April 6th, 2004 @ 01:49PM from the...
7
by: Gasten | last post by:
Hello. The last weeks I've been coding a roguelike (you know, like nethack) in python using the nCurses library. Some week ago I ran into a problem: When I made the object for messagebar-output, I...
8
by: seberino | last post by:
I'm semi-seriously wondering if snake jokes are valid in the Python community since technically, Python came from Monty Python, not slithery animals. Problem is I don't know that anyone born...
1
by: Xah Lee | last post by:
Of interest: $B!V(B... what society overwhelmingly asks for is snake oil. Of course, the snake oil has the most impressive names --otherwise you would be selling nothing-- like "Structured...
13
by: anthony | last post by:
I'm creating a report that will present information split into several sections with each section dealing with a particular aspect of data. No problem there. However, one of the sections will...
0
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...
0
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
0
BarryA
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
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...
0
marktang
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,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.