請各位賜教
為什麼我在WINˍTC下運行這樣的語句這行
char string[150]="good come on"/*顯示錯誤*/
而把它變成下面的格式雙可以:
char string[150];
string[]="good come on";
很多書上都是用的第一種方法。
為什麼我在WINˍTC下運行這樣的語句這行
char string[150]="good come on"/*顯示錯誤*/
而把它變成下面的格式雙可以:
char string[150];
string[]="good come on";
很多書上都是用的第一種方法。
2006-05-23 17:20
為什麼我在WINˍTC下運行這樣的語句這行
char string[150]="good come on"/*顯示錯誤*/
而把它變成下面的格式雙可以:
char string[150];
string[]="good come on";
很多書上都是用的第一種方法。
难以置信。真的吗?迄今为止,我认为下列3种方案都是可行的:
⑴ char string[150]="good come on";
⑵ char string[150]={ "good come on" };
⑶ char string[ ]="good come on";
你说的“雙可以”方法则是不可思议的:
char string[150];
string[ ]="good come on";

2006-05-23 17:31
為什麼我在WINˍTC下運行這樣的語句這行
char string[150]="good come on"/*顯示錯誤*/
而把它變成下面的格式雙可以:
char string[150];
string[]="good come on";
很多書上都是用的第一種方法。
string[150]="good come on" 后面有加分号吗?
2006-05-23 17:42

2006-05-23 17:47
2006-05-23 18:30
2006-05-23 19:12
2006-05-24 07:57
2006-05-24 08:23
如果是您的第二种
那应该是这样的
char string[150];
strcpy(string,"good come on");
除了初始化可以用等号,其它的时候好像只能用strcpy();

2006-05-24 08:27

2006-05-24 10:56