For scanning a complete line from a file in c++:
when I am using inFile >> s; where s is a string and inFile is an external file, it is just reading the first first word from the line.
Full code: (I am just trying to scan the file line by line and print the length of lines. )
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
int main()
{
ifstream inFile;
inFile.open("sample.txt");
long long i,t,n,j,l;
inFile >> t;
for(i=1;i<=t;i++)
{
    inFile >> n;
    string s[n];
    for(j=0;j<n;j++)
    {
        getline(inFile,s[j]);
        l=s[j].length();
        cout<<l<<"\n";
    }
}
return 0;
}
Sample.txt
2
3
ADAM
BOB
JOHNSON
2
A AB C
DEF
First integer is test case followed by no of words to come.
 
     
    