• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Hanging
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Hanging


  • Subject: Hanging
  • From: Michael <email@hidden>
  • Date: Wed, 5 Jul 2006 17:11:05 -0700

Could I ask someone to run this little program. It is an attempt to complete an exercise in K&R...but here is the problem.

Under Xcode it compiles ok...but when I step through it, it hangs where I have indicated. It would really be nice if someone else could replicate this and help me understand what the issue is. The code itself does is really a "dummy" run for a later exercise.
thanks in advance:


X-code 2.3
Compiled with the Standard Tool.

>>>>>>



# include <stdio.h>
# include <string.h>
# define MAXNUM 10
# define TESTCHAR 'T'

int getops(char s[]);
int main (){
char s[MAXNUM], type;
while (  (type=getops(s)) != EOF){
switch (type) {

case 'T':
printf("%s\n", s);
break;
        }



}

return 0;


}

/*****GETOPS******/
int getch(void);
void ungetch(int c);
int getops(char s[]){

int c, i;
while ( (c = getch()) == ' ' || c =='\t');
for ( i=0; i <= 1; i++)  /*****HANGS HERE***/
ungetch('T');



}

/***** GETCH & UNGETCH*****/
# define MAXBUFF 10
char buffer[MAXBUFF];
int buffp=0;
int j=1;
int getch(void){
return (buffp > 0) ? buffer[--buffp]: getchar() ;



}

void ungetch(int c){
printf("Printing line %d\n", j++);


}

/******
Output("p" entered):



>>/beginning of output/<<

p
Printing line 1
Printing line 2
Printing line 3
Printing line 4


>>/end of output/<<

**/ _______________________________________________
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
  • Follow-Ups:
    • Re: Hanging
      • From: Dan White <email@hidden>
    • Re: Hanging
      • From: David Rogers <email@hidden>
  • Prev by Date: Re: Xcode and external bundles
  • Next by Date: Re: XCode Dock Icon
  • Previous by thread: Re: Const structure pointer as template argument
  • Next by thread: Re: Hanging
  • Index(es):
    • Date
    • Thread