如何讀取未知長度的輸入字符串?如果我不知道這個詞有多長時間,我就不能寫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;}請輸入長度=5的字符串你好這是字符串:你好
如何讀取未知長度的輸入字符串?
慕碼人8056858
2019-07-12 09:55:20