Thursday, July 30, 2009

Why does this C function not work every time?

//Function to allow user to read text at own speed before continuing


int CONTINUE (void) {


fflush(NULL);


char Cont[2]={0};


printf("\n\n\n(Press \'return\' to continue.)\n");


fgets(Cont, 2, stdin);


if (Cont[0] == '\n') {


printf("\n\n\n\n...");


return 0;


}








else {


printf("\nInput error.\nNext time enter \'return\'. On its own. Allow us to bitchslap you for your insolence!\n*You lost 100 HP.*\nOn with the game then...");


Main.HP=Main.HP-100;


return Main.HP;


}


}

Why does this C function not work every time?
I think the fflush needs to be done on stdin not NULL. In addition you might look at





http://www.kbalertz.com/kb_41159.aspx





it suggests using rewind(stdin).
Reply:sign into xpforum and you will get help there , it's like here q %26amp; a , they all seem to know about a p.c
Reply:ok try to clear Cont[0] = '_'; before the get


and verify if its stay at _ then tell me





good luck

land survey

No comments:

Post a Comment