E
Eoghan
Hi there! I have two simple questions about a program i'm doing:
1) if I write:
enum logic {VERO=1, FALSO=0};
logic trovato=VERO;
Is this correct according to the ANSI '89 standard?
2) I have these lines:
void GetInfo(void)
{
int i=0;
char Dato[256];
printf("Inserire i dati numero %i: ", ++i);
scanf("%[^\n]", Dato);
fflush(stdin);
while( strcmp(Dato, "FINE") )
{
Riempi_Info(Dato); //Fills an array called Estremi
printf("Sigla: %s \t Inizio: %f \tFine: %f\n", Sigle[Nstr],
Estremi[Nstr][0], Estremi[Nstr][1] );
i++;
Nstr++;
printf("Inserire i dati numero %i: ", i);
scanf("%[^\n]", Dato);
fflush(stdin);
}
return;
}
Why does the program crash if I don't call the function fflush after
each scanf? And why in windows can't I use the function fpurge instead?
1) if I write:
enum logic {VERO=1, FALSO=0};
logic trovato=VERO;
Is this correct according to the ANSI '89 standard?
2) I have these lines:
void GetInfo(void)
{
int i=0;
char Dato[256];
printf("Inserire i dati numero %i: ", ++i);
scanf("%[^\n]", Dato);
fflush(stdin);
while( strcmp(Dato, "FINE") )
{
Riempi_Info(Dato); //Fills an array called Estremi
printf("Sigla: %s \t Inizio: %f \tFine: %f\n", Sigle[Nstr],
Estremi[Nstr][0], Estremi[Nstr][1] );
i++;
Nstr++;
printf("Inserire i dati numero %i: ", i);
scanf("%[^\n]", Dato);
fflush(stdin);
}
return;
}
Why does the program crash if I don't call the function fflush after
each scanf? And why in windows can't I use the function fpurge instead?