HKGalden學術臺
發表文章發起投票
c programming 求救
整緊個function 用黎exit, 但係打Y 同N 都exit 到
有冇巴打可以幫我睇下有咩問題


#include <stdio.h>
#include <stdlib.h>

void terminate()
{
char x;
printf("Are you sure you want to exit? (Y/N) :");
scanf("%c",&x);
fflush(stdin);
if (x = "Y")
{
printf("Press <ENTER> to exit.");
fflush(stdin); getchar();
exit(0);
}
else if (x = "N")
{
main();
}

do
{
printf("Invalid value, please input again.\n\n");
printf("Are you sure you want to exit? (Y/N) :");
scanf("%c",&x);
fflush(stdin);
if (x = "Y")
{
printf("Press <ENTER> to exit.");
fflush(stdin); getchar();
exit(0);
}
else if (x = "N")
{
main();
}
}
while (x != "Y" || x != "N");
}


int main()
{
terminate();
return 0;
}




Good0Bad0
2014/12/07, 5:12:39 下午
本貼文共有 0 個回覆
此貼文已鎖,將不接受回覆
發表文章發起投票