D
drmario
Here's what I got:
ifstream File; // already initialized and associated with a file
input stream
unsigned short r = 1; // a counter to tell me if this is the loop's first
iteration
do {
if( (File.peek() == 32) && r)
return 0;
else if ... snip
else ... snip
r=0;
} while(some condition)
I've done this because I want to know if my function encounters the newline
character before everything else. If it does, I need it to return false.
If it doesn't, I need it to make r=0, so that on the next iteration if it
happens to find a newline char, but it's not the first iteration, it won't
return false.
What I don't like is that let's say 100 iterations of this loop happens
before it returns anything. I'm wasting processor time by assigning 0 to r
every single iteration.
Therefore my question is: is there not a way for me to change that if ( )
statement up there so that I can somehow see if this is the first iteration
of the do...while() loop, WITHOUT having to use a variable and waste
processor time assigning it all the time?
thanks
Mario
ifstream File; // already initialized and associated with a file
input stream
unsigned short r = 1; // a counter to tell me if this is the loop's first
iteration
do {
if( (File.peek() == 32) && r)
return 0;
else if ... snip
else ... snip
r=0;
} while(some condition)
I've done this because I want to know if my function encounters the newline
character before everything else. If it does, I need it to return false.
If it doesn't, I need it to make r=0, so that on the next iteration if it
happens to find a newline char, but it's not the first iteration, it won't
return false.
What I don't like is that let's say 100 iterations of this loop happens
before it returns anything. I'm wasting processor time by assigning 0 to r
every single iteration.
Therefore my question is: is there not a way for me to change that if ( )
statement up there so that I can somehow see if this is the first iteration
of the do...while() loop, WITHOUT having to use a variable and waste
processor time assigning it all the time?
thanks
Mario