在一个答案中有一个有趣的声明:" 使用该函数几乎总是一个坏主意,fscanf()因为它可以在失败时将文件指针留在未知位置.我更倾向于使用fgets()每条线路然后进入sscanf()."
你可以扩展何时/为什么它可能更好用fgets()和sscanf()阅读一些文件?
#include <stdio.h>
#define MAX 5
int stk[MAX];
int top=-1;
main()
{
char ch;
void push();
void pop();
void display();
do
{
printf("1. Push\n");
printf("2. Pop\n");
printf("3. Display\n");
ch=getchar();
if(ch=='1')
push();
if(ch=='2')
pop();
if(ch=='3')
display();
printf("Do u want to continue y/n");
ch=getchar();
}while(ch=='y'||ch=='Y');
}
void push()
{
}
void pop()
{
}
void display()
{
}
Run Code Online (Sandbox Code Playgroud)
我完成推送操作的那一刻...程序打印""你想继续y/n"并退出....不等待用户输入""y/Y"
请帮忙