S
Shadow503
Here is my code:
#include <iostream>
using namespace std;
int vWidth;
int vHeight;
char mapdata[999][999];
/* Map Data Array
x-Boundary
~-Water
o-Island
*/
void drawmap (){
cout << "\n";
int i;
int j;
i=0;
j=0;
while (mapdata[0]!='x'){
while (mapdata[0][j]!='x'){
cout << mapdata[j];
j++;
}
i++;
}
}
int main(){
cout << "Enter the Width of the map:\n";
cin >> vWidth;
cout << "Enter the Height of the map:\n";
cin >> vHeight;
int i;
//Set boundries
for (i=0; i<=vHeight; i++) {
mapdata[vWidth]='x';
}
for (i=0;i<=vWidth; i++){
mapdata[vHeight]='x';
}
//Draw the map
drawmap ();
return 0;
}
I keep getting a segmentation fault error after I enter the height.
I'm on Ubuntu 6.06, using the Anjuta IDE and compiling with g++.
#include <iostream>
using namespace std;
int vWidth;
int vHeight;
char mapdata[999][999];
/* Map Data Array
x-Boundary
~-Water
o-Island
*/
void drawmap (){
cout << "\n";
int i;
int j;
i=0;
j=0;
while (mapdata[0]!='x'){
while (mapdata[0][j]!='x'){
cout << mapdata[j];
j++;
}
i++;
}
}
int main(){
cout << "Enter the Width of the map:\n";
cin >> vWidth;
cout << "Enter the Height of the map:\n";
cin >> vHeight;
int i;
//Set boundries
for (i=0; i<=vHeight; i++) {
mapdata[vWidth]='x';
}
for (i=0;i<=vWidth; i++){
mapdata[vHeight]='x';
}
//Draw the map
drawmap ();
return 0;
}
I keep getting a segmentation fault error after I enter the height.
I'm on Ubuntu 6.06, using the Anjuta IDE and compiling with g++.