M
mdh
They say one learns more from one's errors...and I am certainly keeping
that up. The following is code from K&R explaining external
variables...but that is not directly relevant here. When I wrote it, I
initially wrote the code immediately below. But this hangs.
(c is an integer, which may or may not contain a digit. s is a
character array and getch() is a function which gets the next
character)
if ( isdigit(c) )
while ( s[++i] = c = isdigit(getch()));
When I went back and finally saw what I perceived to be a small
difference, the code worked as intended.
if ( isdigit(c) )
while (isdigit ( s[++i] = c = getch()));
I have not included all the code, as I do not believe it is relevant.
Is this what is happening in the first incorrect code...?
When getch() returns a non-digit, the code stops just as it is supposed
to do, thus prevents assignment of c and s[] so the next line of code
is never reached, or is there something else which I have missed as
usual?
that up. The following is code from K&R explaining external
variables...but that is not directly relevant here. When I wrote it, I
initially wrote the code immediately below. But this hangs.
(c is an integer, which may or may not contain a digit. s is a
character array and getch() is a function which gets the next
character)
if ( isdigit(c) )
while ( s[++i] = c = isdigit(getch()));
When I went back and finally saw what I perceived to be a small
difference, the code worked as intended.
if ( isdigit(c) )
while (isdigit ( s[++i] = c = getch()));
I have not included all the code, as I do not believe it is relevant.
Is this what is happening in the first incorrect code...?
When getch() returns a non-digit, the code stops just as it is supposed
to do, thus prevents assignment of c and s[] so the next line of code
is never reached, or is there something else which I have missed as
usual?