Macro help

Mike Percy grimlok at hubcap.clemson.edu
Fri Mar 9 06:10:39 AEST 1990


Awhile back I saw some code which used a macro that had a do...while(0)
loop in it.  At the time I thought, hey that's a good idea, but now that I need
to do something while could use this I'm stuck.   
 
Here's my situation: 
I am reading chars. When I hit '\n' I need to skip the first 6 chars on
the next line ( anyone guess why?) and return the next char.  Effectively this
removing all "\nxxxxxx" from the stream.

I tried this:
  
#define input(ch) \ 
   ((ch) = getchar) != '\n' ? (ch) : \
   (do { int i = 5; while(i--) (void) getchar(); } while(0);), getchar()
 
But this doesn't seem to work.  Anyone that can help me out there?



More information about the Comp.lang.c mailing list