#include <iostream>
usingnamespace std;
void map();
int main()
{
void map();
return 0;
}
void map()
{
int fullMap[20];
int x = 0;
int y = 0;
int px = 0;
int py = 0;
for (x = 0; x < 21; x++)
{
for (y = 0; y < 21; y++)
{
fullMap[x,y] = 1;
}
}
for (px >= 0; px < 21; px++)
{
for (py >= 0; py < 21; py++)
{
if (fullMap[px,py] = 1)
{
cout << ".";
}
}
}
}
I know that at the end, it won't show what I'm trying to get it to show, but for now I'd be thrilled if it showed anything. No errors pop up when it's compiled, but their are some warnings, including 'statement has no effect' for the last two for loops. Anybody see any horribly stupid mistakes?
// This may be wrong, but does the fact that the period in cout << "."; is surrounded by double quotes rather than single quotes? I'm not sure if it's an issue, but I just remember seeing anything with a single character surrounded by single quotes.
This program is flawed, unfortunately, and you may get the classic, one and only mother and Agent Smith of all C++ runtime errors, the segmentation fault. Replacing all the 21s with 20s should prevent it.
Oh. Also. Why is nothing printing? You can fix it by getting rid of the the void in line 9.
(In short, fill it in with whitespace... no, but seriously, ditch that void).
HUZZAH! It works! Though I didn't mean for it to fill up five lines all the way across the screen, but I sorta expected that.
@ Albatross
Why exactly does switching 21's for 20's make it work? I would have thought that having their be a less-than sign would have made it stop at 20.
Ah, I see.
Final question (maybe): how would I clear the screen without using system("CLS")? Everywhere I look people say "Don't use it, it reduces portability", but I need to have the computer redraw the map as it changes.
You could print 128 newlines to the scree- ah, actually, I'll link to an article that has a lot of info on clearing the console. It should help! http://www.cplusplus.com/forum/articles/10515/