if i set up a #define FLUSH while((c=getchar()) != '\n') its quite happy with me using the macro
Code:
#include <stdio.h>
#include <stdlib.h>
#define FLUSH while((c=getchar()) != '\n')
void flush_line(void);
int main()
{
int x = -1, y = 0;
//char ch;
printf("please enter a number: ");
scanf(" %1d", &x);
flush_line();
printf("please enter a second number: ");
scanf("%1d", &y);
printf("\n x = %d and y = %d\n", x, y);
return 0;
}
void flush_line(void)
{
char c;
FLUSH;
}
however if i delete the char c it doesn't work any more and i get a compiler error saying first time use of variable c.
Is there a way round this or am i doing something wrong
many thanks
coop