0
我要分配從標準輸入一個struct值(即可以是最多50個字符)「的char [LENGTH]」,但正在錯誤:Ç - 不相容類型分配時輸入的內容從類型「字符*」
Incompatible types when assigning to type 'char[50]' from type 'char *'
#include <stdio.h>
#include <stdlib.h>
#define MAX_LEN 50
struct msgbuf {
char mtext[MAX_LEN];
};
int main (int argc, char *argv)
{
struct msgbuf m;
char in[MAX_LEN];
scanf ("%s", in);
m.mtext = in;
}
你爲什麼要將'in'強制轉換爲'char *'? – mstbaum 2015-03-31 19:00:16
@mstbaum既然沒有什麼區別,我把它編輯出來 – BDillan 2015-03-31 19:01:44
你不能指定一個數組到另一個。 – HuStmpHrrr 2015-03-31 19:02:25