Click here to Skip to main content
15,890,415 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
How do i read one word at a time from a text file in which the words are separated by a white space. The pointer should also move along. I mean i dont want to use the String.split method after reading a line. I want to read words and insert a word at a particular position in the file. Is there a simple way to do this??
Posted

StreamReader has a Read() method that reads one character at a time. It might be more efficient to use the (buffered version[^]) at the cost of getting a few extra characters and more complexity but getting one char at a time is slow.

All you then need do is loop, checking each each char in turn.
 
Share this answer
 
Hi,
Just read line by line and token it on space using
<pre lang="c++">arr = strtok(buffer,' ');</pre>

check the correct syntax from internet.
arr will have the words.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900