Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.


Little Problem with my code

This topic is 6501 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello everyone, I'm having a problem with the snippet of code below. The program goes into an infinite loop when entering the while loop, and I can't figure out why. The code is part of a small console app I'm working on, and windows.h has been include so that the LPSTR variables work.

int MapEditor(void)
	int MapArray[XMAPSIZE][YMAPSIZE];	// Store the map's values

	int XValue = 0;						// Temporary X Value

	int YValue = 0;						// Temporary Y Value

	int InputValue = 0;					// Temporary Input Value

	LPSTR Filename = 0;					// Filename of the map

	LPSTR Quit = "n";					// Should we quit

	cout << "Enter the Filename: ";
	cin >> Filename;

	while (Quit != "y" || "Y")
		cout << endl << endl << "Enter the X coordinate: ";
		cin >> XValue;

		cout << endl << endl << "Enter the Y coordinate: ";
		cin >> YValue;

		cout << endl << endl << "Enter the value: ";
		cin >> InputValue;

		MapArray[XValue][YValue] = InputValue;

		cout << endl << endl << "Do you wish to quit(Y/N): ";
		cin >> Quit;

	cout << endl << endl << "Saving File...";
	ReadWriteMap(Filename, MapArray, true);

	cout << endl << endl << "-File Saved-";


Anyone got an idea what's going on. Thanks, Derek Edited by - Reaptide on 11/30/00 2:45:42 PM

Share this post

Link to post
Share on other sites
Try to change the while () to
while (Quit != "y" && Quit != "Y")

Take a minute to think about it.

Edited by - VolkerG on November 30, 2000 3:51:27 PM

Share this post

Link to post
Share on other sites
Don't use LPSTR's for your data. use:
char Filename[256]; // Use array of char's

char Quit = 'n'; // One char, no need for more

// Change the *while* code to this

while (Quit == 'n')
// code...


Worked for me.

Edited by - jt_845s on November 30, 2000 4:03:06 PM

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!