Mail Archives: djgpp/2000/05/29/07:46:02
In article <8grfga$h00$1 AT nnrp2 DOT deja DOT com>, <joel_hansell AT my-deja DOT com> wrote:
>In C++ class, I'm supposed to write a simple
>slalom game.
Chances are that if you can pare down the code to the bit that causes the
crash, and repost it in comp.lang.c++, it'll be obvious to them,
especially if it's just a pointer problem that's stomping all over the
stack.
If you want to debug using gcc/RHIDE, it has its own very useful debugging
tool. Without wanting to be patronising, look at the "Debug" menu. F7/F8
combinations allow you to step through the code until *pow* - you get a
segmentation fault at the offending line.
> Port level[]; /* array of Ports, should this
>be "Port* level[]" or even "Port[] level"?
>Perhaps I must define the size of the array, like
>"Port* level[5]"? /*
What you might want to do is define a pointer, Port *level. This pointer
can then be made to point to an array of any size you want with:
level = new Port[5];
// ...
delete level[];
// ...
level = new Port[250];
Simply declaring Port level[] isn't (I think) proper C++; certainly it
rings alarm bells from this C programmer, but C++ is still a closed book
to me.
So: you can declare Port level[10], or Port *level, where the latter
allows you to change the size of the array starting at address "level".
J-P
- Raw text -