Been a long time since using C++ but the error/message I keep getting is from Windows. Add in the fact that my program is working ( mostly ) then I can only assume that it's something completely outside of what I know.

The message I get is simply "<insert program name> has encountered a problem and needs to close. We are sorry for the inconvenience." The specifics of my program are as follows: it is currently setup as a project with 2 .cpp files and one .h file. One .cpp file is the main file with the other one running function definitions. The .h file just contains the prototypes. There is only one function that I am using, code posted below.

I've gotten the same error using different variations of this setup. I know that the function itself works because I've used it in other programs and in the original main file. If it's a really simple problem unrelated to Windows, sorry for posting in the wrong forum.

Thank you.

EDIT: When I said "works ( mostly )" I meant that the program starts, runs, but fails to close and displays aforementioned message. The main program itself works and as far as I know there should be nothing inside it that should cause this problem.

06-27-2010

Elysia

This error means you've done something illegal. The most common error is dereferencing an invalid pointer.
The snippet you shows does not demonstrate the problem.

Thank you for the reply and the tip. I've only showed those snippets because the problem only started to occur once I started separating the code into different files. For confirmation, I will post the main code later.

Sadly, I do not understand your comment on "magic numbers". Yes, the number 13 used in the wait_loop() may seem arbitrary but that number is used because of the value it represents from getch(); it is the vale used for the <Enter> key.

Thank you for suggesting getting a new compiler, but I would rather not change compilers unless the compiler is the problem ( if it works, I'm happy with that )

This should not compile!
You have an undefined numbers of objs in room, which you cannot have. You must specify a size! You are trying to access objects that do not exist.

Magic numbers refers to arbitary numbers in your code that means little or nothing. What does "13" mean, for example? If you used '\r' instead, it would be clear. It doesn't matter that it came from getch, you can ALWAYS compare to chars.

06-27-2010

teck

Quote:

Originally Posted by Elysia

This should not compile!
You have an undefined numbers of objs in room, which you cannot have. You must specify a size! You are trying to access objects that do not exist.

Magic numbers refers to arbitary numbers in your code that means little or nothing. What does "13" mean, for example? If you used '\r' instead, it would be clear. It doesn't matter that it came from getch, you can ALWAYS compare to chars.

Thank you for inadvertently assisting me through a long, drawn-out and needless set of comments to the answer of my problem. Perhaps you should compare my comment to an int as you would clearly understand it better and the unnecessary effort required to properly compare it would most likely be appreciated by you.

Furthermore, without any superior analytical processes your comment would've been completely unhelpful and argumentative in nature.

P.S. "Cry me a river, build me a bridge, do us all a favour and jump off of it."

06-27-2010

Elysia

If you oh so dislike being told things, then perhaps you should simply leave. This forum doesn't "merely" specialize in helping out newbies solve their problems, but also help them write portable and standards compliant code.
If you don't like it, leave.
Error 1 error C2133: 'room::obj' : unknown size