#include <stdio.h>
#include <stdlib.h>
#include <string.h>
char *method1(void)
{
static char a[4];
scanf("%s\n", a);
return a;
}
int main(void)
{
char *h = method1();
printf("%s\n", h);
return 0;
}
当我运行上面的代码时,提示框会要求我输入两次(但我的代码中只使用了scanf
一次)。为什么会这样呢?(我输入了'jo';它要求我再次输入,所以我又输入了'jo'。然后它只打印出了'jo'一次。)