[問題] 一個小程式的debug
各位大大~想請教大家一個小問題~以下為這個程式的程式碼~
struct student {
char name[20];
int score;
};
typedef struct student ST;
#include <stdio.h>
#include <stdlib.h>
int main ()
{
ST* stname;
stname->name="Jonh";
stname->score=90;
printf("%s的分數為%d\n", stname->name, stname->score);
system("PAUSE");
return 0;
}
用Dev-C++編譯之後出現
incompatible types in assignment of `const char[5]' to `char[20]'這樣的錯誤~
想請問stname->name="Jonh";這段要如何改才OK~先感謝各位網友了^^~
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 220.136.166.190
→
10/17 02:09, , 1F
10/17 02:09, 1F
→
10/17 02:13, , 2F
10/17 02:13, 2F
→
10/17 02:14, , 3F
10/17 02:14, 3F
→
10/17 02:16, , 4F
10/17 02:16, 4F
推
10/17 10:00, , 5F
10/17 10:00, 5F
推
10/17 10:03, , 6F
10/17 10:03, 6F
→
10/17 14:41, , 7F
10/17 14:41, 7F
→
10/17 14:42, , 8F
10/17 14:42, 8F
→
10/17 15:26, , 9F
10/17 15:26, 9F
→
10/17 15:26, , 10F
10/17 15:26, 10F
→
10/17 15:26, , 11F
10/17 15:26, 11F
→
10/17 15:28, , 12F
10/17 15:28, 12F
→
10/17 15:29, , 13F
10/17 15:29, 13F
→
10/17 15:43, , 14F
10/17 15:43, 14F
C_and_CPP 近期熱門文章
PTT數位生活區 即時熱門文章