Could someone explain why this single cout << endl; statement is breaking my code? I cannot for the life of me figure out what is wrong. If I rem out the cout the code works, if i leave it netbeans says there is no exe file to open.
#include <iostream>
#include <iomanip>
usingnamespace std;
// This function prints a box of size x size/2 '*'s
void box(int size) {
int a;
int b = size;
int d;
int e;
int f;
int g;
for (a=0; a<size; a++){
cout << "*";
}
cout << endl;
if (b%2 != 0)
b = (b-1)/2;
else
b = b/2;
b = b - 2;
g = size - 2;
for (d=0; d<b; d++){
cout << "*";
for (e=0; e<g; e++)
cout << " ";
cout << "*" << endl;
}
for (f=0; f<size; f++){
cout << "*";
}
cout << endl; // <-------WHY IS THIS RUINING MY CODE?
}
int main() {
int i;
int input;
for (i = 0; i < 3; i++) {
cout << "Enter box size: ";
cin >> input;
box(input);
}
cout << "The end." << endl;
}
This runs OK for me through the compiler linked on the forum (the little gear icon at the top right of the code box.) Could you have the code open unsaved while your trying to run the program? I'm sorry I'm not familiar with how projects are set up in netbeans.
Just ran it on Xcode and can confirm it runs fine.
I haven't used Netbeans in a while, but make sure that it's configured properly to run a program instead of doing something else like test it or something.