I have the folowing code in C++:
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
using namespace std;
int main(int argc, char **argv)
{
int N;
string s;
char str[100];
scanf("%d",&N);
for(int i=0; i<N; i++)
{
fflush(stdin);
fgets(str,100,stdin);
s = str;
cout << s << endl;
}
return 0;
}
The code is save in an archive test.cpp.
Using the terminal on Linux Ubuntu for compile:
g++ -c hello.cpp
g++ -o hello hello.o
I have an archive test.in that will be the input:
5
God of War
Grand Theft Auto
The Smurfs
Final Fantasy
Call of Duty
Runing the command in terminal:
./test < test.in
The output will be:
rogerio@rogerio-Aspire-5741Z:~/Documentos$ ./teste < teste.in
God of War
Grand Theft Auto
The Smurfs
Final Fantasy
rogerio@rogerio-Aspire-5741Z:~/Documentos$
Because the line "Call of Duty" is jumped?