while statement

M

muser

I have the following problem

do{

something;

while(temp1, != '\n');

compiler error: syntax error !=.

How can I write this code differently to accept the !=.


Also, and there is so many who have helpped in the past and know
exactly what I'm still working on.

How do I reset a file that is already been read, in effect once the
EOF has been reached, how would I be able to read the file over and
over again? Does the tellg function do this at all?
 
J

John Carson

muser said:
I have the following problem

do{

something;

while(temp1, != '\n');

compiler error: syntax error !=.

How can I write this code differently to accept the !=.

Get rid of the comma for a start.
 
T

Thomas Matthews

muser said:
I have the following problem

do{

something;

while(temp1, != '\n');
=-+-=-+-=-+-=-+-=-+-=-+-=-+-=-+-=-+-=-+-=-+-=-+-=-+-=-+-=-+-=-+-=-+-=
Remove the ',' (comma):
while (temp1 != '\n');
Don't use commas unless you absolutely know what you are doing.
I rarely use them.
=-+-=-+-=-+-=-+-=-+-=-+-=-+-=-+-=-+-=-+-=-+-=-+-=-+-=-+-=-+-=-+-=-+-=

compiler error: syntax error !=.

How can I write this code differently to accept the !=.


Also, and there is so many who have helpped in the past and know
exactly what I'm still working on.

How do I reset a file that is already been read, in effect once the
EOF has been reached, how would I be able to read the file over and
over again? Does the tellg function do this at all?
=-+-=-+-=-+-=-+-=-+-=-+-=-+-=-+-=-+-=-+-=-+-=-+-=-+-=-+-=-+-=-+-=-+-=
Once a file has reached EOF, it cannot be read again
_from_that_position_. You have to clear the status and rewind or
relocate the file position:
ifstream myfile;
myfile.clear(); // Clear the EOF status.
myfile.seekg(0); // Set file position to beginning.
=-+-=-+-=-+-=-+-=-+-=-+-=-+-=-+-=-+-=-+-=-+-=-+-=-+-=-+-=-+-=-+-=-+-=


--
Thomas Matthews

C++ newsgroup welcome message:
http://www.slack.net/~shiva/welcome.txt
C++ Faq: http://www.parashift.com/c++-faq-lite
C Faq: http://www.eskimo.com/~scs/c-faq/top.html
alt.comp.lang.learn.c-c++ faq:
http://www.raos.demon.uk/acllc-c++/faq.html
Other sites:
http://www.josuttis.com -- C++ STL Library book
 
R

Ron Natalie

muser said:
while(temp1, != '\n');

compiler error: syntax error !=.

How can I write this code differently to accept the !=.

Get rid of the comma. Why did you put it there?
 
J

John Harrison

How do I reset a file that is already been read, in effect once the
EOF has been reached, how would I be able to read the file over and
over again? Does the tellg function do this at all?

No, you need clear and seekg, in that order.

my_file.clear();
my_file.seekg(0);

john
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,141
Messages
2,570,813
Members
47,357
Latest member
sitele8746

Latest Threads

Top