Given a text file just like (file.txt):
1234567A (THIS IS TAB) Peter, ABC (THIS IS TAB) 23523456
1345678A (THIS IS TAB) Michael CDE (THIS IS TAB) 23246756
1299283A (THIS IS TAB) Andy (THIS IS TAB) 98458388
ifstream inFile; string s; string id; string name; int phoneNo; inFile.open("file.txt"); while (!inFile.eof()) { getline(inFile, s, '\t'); } How can I extract a string of a line into different fields? For example, when I print s, it gives 1234567A. I have tried some techniques found in Stackoverflow, however, I cannot achieve the goal.
Thanks.
One more thing I want to ask is if the third field (i.e. phoneNo) consists of 1-3 elements,
1234567A (THIS IS TAB) Peter, ABC (THIS IS TAB) 23523456 (THIS IS TAB) 12312312
1345678A (THIS IS TAB) Michael CDE (THIS IS TAB) 23246756
1299283A (THIS IS TAB) Andy (THIS IS TAB) 98458388 (THIS IS TAB) 123123123 (THIS IS TAB) 123123123
How can I distinguish the number of phoneNo?