Break two loops with a error
Hey Everybody,
I wrote this code:
Code:
#include <windows.h>
#include <iostream>
using std::cout;
using std::cin;
using std::endl;
using std::fixed;
int main()
{
int a, line, col, ord;
HANDLE hOut;
COORD Position;
hOut = GetStdHandle(STD_OUTPUT_HANDLE);
cout << "What the number of line and column?";
cin >> ord;
for(line=0; line<=ord-1; line++){
Position.Y = line+2;
for(col = 0; col<=ord-1; col++){
Position.X = 3+(col*8);
SetConsoleCursorPosition(hOut, Position);
cout << "a" << col <<":";
if( ! ( cin >> a ) ){
cout << "It's not a number";
}
if (col == ord){ cout << endl; }
}
}
system("pause");
return 0;
}
So the bold line, the program tests the variable a.
How can I finish the program in this line? If I use exit(1) or Return 0, The window close immediately... How can I finish the program with a error mensage, and restart the program?
Thanks, have a good night.