| 發表文章 | 發起投票 |
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;
}


有冇巴打可以幫我睇下有咩問題
#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;
}


本貼文共有 0 個回覆
此貼文已鎖,將不接受回覆
| 發表文章 | 發起投票 |