i want my program to read a .dat file containing characters arranged like below:
A
B
C
B
A
B
A
B
C
how do i let my program know that it should take a value, then skip the whitespace, then take the value after the whitespace until end of file? I was give some codings that look like this
infile %26gt;%26gt; temp %26gt;%26gt; ws; //whats temp? a char?
C++ read file help?
I'll assume you have included %26lt;iostream%26gt;, and ifstream infile.
Actually, the easier way to do it is...
char temp;
while (infile.peek() %26amp;%26amp; !infile.eof()){
infile %26gt;%26gt; temp;
}
Anyway, this is just one way to do it. I like to use peek() to know the eof is reached.
survey for cash
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment