M
mdh
I am just trying to figure out if this is intended behavior, or whether
I am missing something...(probably the latter).
The example given (p96, K&R) is meant to illustrate pointer behavior.
K&R say the example "break(s) a stream of characters into integer
values"
The relevant code is: ( I think)
(in Main)
for (i=0; i < SIZE && getint(&arr) != EOF; i++);
and I believe the relevent code in getint is:
while ( isspace(c=getch()));
if ( !isdigit (c) && c != EOF && c != '+' && c != '-'){
ungetch(c);
return 0;
where getch() and ungetch() are K&R versions of pushing/getting the
extra character to/from a buffer.
My question is this:
If my input is something like: " 89 76 45 -90" the out put is the same
(if I print the array)
but as soon as I introduce a character other than a digit, it goes into
an endless loop, and exits when
i < SIZE is false.
Is this the intended behavior?
Thanks in advance.
I am missing something...(probably the latter).
The example given (p96, K&R) is meant to illustrate pointer behavior.
K&R say the example "break(s) a stream of characters into integer
values"
The relevant code is: ( I think)
(in Main)
for (i=0; i < SIZE && getint(&arr) != EOF; i++);
and I believe the relevent code in getint is:
while ( isspace(c=getch()));
if ( !isdigit (c) && c != EOF && c != '+' && c != '-'){
ungetch(c);
return 0;
where getch() and ungetch() are K&R versions of pushing/getting the
extra character to/from a buffer.
My question is this:
If my input is something like: " 89 76 45 -90" the out put is the same
(if I print the array)
but as soon as I introduce a character other than a digit, it goes into
an endless loop, and exits when
i < SIZE is false.
Is this the intended behavior?
Thanks in advance.