I an trying to figure out why this program will compile, and execute, however does not display any data that is part of the program.
#include <iostream>
#include <cstdlib>
using namespace std;
int main (int argc, char *argv[]) {
char buffer[23][80];
for(int a = 0; a < 23; a++) {
for(int b = 0; b < 80; b++) {
buffer[a][b] = ' ';
}
}
char in[80];
char text[75];
int x, y;
bool quit = false;
cout << endl;
while (quit == false) {
cin.getline(in, 80);
if(in[0] == 'r' && in[1] == 'e' && in[2] == 's' && in[3] == 'e' && in[4] == 't') {
for(int a = 0; a < 23; a++) {
for(int b = 0; b < 80; b++) {
buffer[a][b] = ' ';
}
}
} else {
x = atoi((const char*)in[0]) * 10 + atoi((const char*)in[1]);
y = atoi((const char*)in[2]) * 10 + atoi((const char*)in[3]);
for(int a = 4; a < 80; a++) {
buffer[y][x + a - 4] = in[a];
if((int)in[a] == 0) {
buffer[y][x + a - 4] = ' ';
}
}
}
cout << endl;
for(int a = 0; a < 23; a++) {
for(int b = 0; b < 80; b++) {
cout << buffer[a][b];
}
}
}
return 0;
}
And the output:
bash: line 1: 2209 segmentation fault /home/LINUXHATER/Projects/consolegui/bin/Debug/consolegui
Also, I am ironically using ubuntu linux, MonoDevelop IDE and Geany with g++ compiler
Edit:Geany also gives the same error.