Re: Hanging
Re: Hanging
- Subject: Re: Hanging
- From: Greg Guerin <email@hidden>
- Date: Thu, 6 Jul 2006 12:22:19 -0700
Michael wrote:
>while ( (c = getch()) == ' ' || c =='\t');
>for ( i=0; i <= 1; i++) /*****HANGS HERE***/
and later:
>(The problem is that i does not increment when the function call is
>returned to getops from ungetch() )
There are a number of bugs in your code. If I pointed them all out to you,
it would deprive you of the learning experience of finding them. I will
pose some questions instead. You don't have to answer them in a list
posting, unless you want to, but you should be able to answer them all.
If instead of entering "p" you entered "pqr", what is the program's output?
Can you explain why?
Change this line:
printf("%s\n", s);
to this:
printf("in main, got: %s\n", s);
recompile, then enter "pqr" as input again. What is the program's output?
Is the new printf being executed? Explain.
In this code fragment:
while ( (c = getch()) == ' ' || c =='\t');
for ( i=0; i <= 1; i++)
add a line as shown:
while ( (c = getch()) == ' ' || c =='\t');
printf( "in getops, got: %d\n", c );
for ( i=0; i <= 1; i++)
recompile, and enter "pqr" again. What does this show about how the
program works and where the program hangs?
What is the value returned from getops() intended to represent? Is it a
count of chars read, the value of the last char read, the type of
something, or what? Where is that value being produced?
Exactly what does ungetch() do? It clearly increments j and printf's a
line, as evidenced by the output, but what ELSE does it do? Is what it
does consistent with what it should do?
-- GG
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden