What is most efficient way to read a file of integer in each line without opening it? I have a file with ONLY integer in each line, ie: num.txt
100
231
312
...
In my program, I use while loop to read it;
int input = 0;
while(cin >> input)
{
// Assignment
}
I use time a.out <num.txt
to read it in Linux
It turns out that it will take about 15 second (user time) to read 100 million numbers. So I was wondering is there any better way to decrease user time?
Thank you in advance!