I'm new to C++ and writing a simple program that should take integers from a file as ints and output them formatted appropriately. The issue is that the program skips one of the values when outputting. eg (\n representing a new line) "51 123\n -10\n 153 111" would come out as "123\n -10\n 153\n 111\n 0". Also any tips or pointers for bettering my code would be great. Here is my code:
using namespace std;
int main(int argc, char *argv[]) {
size_t i;
int n;
int a, b, c, d, e;
if (argc == 1) {
while (cin >> n) {
cin >> a;
cin >> b;
cin >> c;
cin >> d;
cin >> e;
cout << setw(10);
cout << a << "\r\n";
cout << setw(10);
cout << b << "\r\n";
cout << setw(10);
cout << c << "\r\n";
cout << setw(10);
cout << d << "\r\n";
cout << setw(10);
cout << e;
}
} else if (strcmp(argv[1],"-x")==0) {
/* not used yet */
} else if (strcmp(argv[1],"-o")==0) {
/* not used yet */
}
}
ntocout.nusingwhile ( cin >> n ). That number is not being written out tocout.