Hi,
I am testing a program where I am doing some FILE I/O manipulations. At the end of the program I use a getchar() just to leave the console open. However, the program ignores the getchar and closes the console at once (not leaving me observe the results).
I am only putting the main.c. Sorry for the incomprehensible names of the variables
Do you have any ideas?
Thanks
Code:
int main(void)
{
int sfalma;
typos_stoivas stoiva; //stoiva twn orwn
float oros1,oros2,apotelesma;
char symbolo, apantisi, metathematiki[256];
int i;
FILE *fp;
if ( (fp=fopen("input.txt","r"))==NULL )
{
printf("Error opening file\n");
exit(1);
}
while (!feof(fp))
{
dimiourgia(&stoiva);
metathematiki[0]='\0';
i=0;
while ( (symbolo = (char) fgetc(fp))!= '\n')
{
metathematiki[i]=symbolo;
i++;
if (symbolo >= '0' && symbolo <= '9') //bre8hke oros
{
apotelesma = (float)(symbolo-'0');
othisi(&stoiva,apotelesma,&sfalma);
}
else if ( einai_telestis(symbolo) ) //bre8hke telesths
{
if (symbolo == '!') // An einai paragontiko tote prepei na bgaloyme ena
{ // stoixeio apo ti stoiva
PopValue(stoiva,&oros1,&sfalma);
PopState(&stoiva,&sfalma);
apotelesma = (float) paragontiko((int)oros1);
othisi(&stoiva,apotelesma,&sfalma);
}
else
{
PopValue(stoiva,&oros2,&sfalma);
PopState(&stoiva,&sfalma);
PopValue(stoiva,&oros1,&sfalma);
PopState(&stoiva,&sfalma);
apotelesma = upologismos(symbolo,oros1,oros2);
othisi(&stoiva,apotelesma,&sfalma);
}
}
} // first while
metathematiki[i]='\0';
PopValue(stoiva,&apotelesma,&sfalma);
PopState(&stoiva,&sfalma);
printf("%s=%5.2f\n",metathematiki,apotelesma);
} // second while
fclose(fp);
getchar();
return 0;
}