如果我不知道这个词有多长,我就不会写char m[6];,
这个词的长度可能是十到二十个.如何使用scanf键盘输入?
#include <stdio.h>
int main(void)
{
char m[6];
printf("please input a string with length=5\n");
scanf("%s",&m);
printf("this is the string: %s\n", m);
return 0;
}
Run Code Online (Sandbox Code Playgroud)
请输入一个lenght = 5
的字符串
你好
这是字符串:hello