為二維字元陣列賦值
阿新 • • 發佈:2019-01-06
假設有一個二維陣列
Code:- char article[3][20]={'/0'};
若要為 article[0] article[1] article[2] 賦值
Code:- //article[0]={"somewords here"}; 這樣的形式是不正確的。
正確的寫法應該是
Code:- strcpy(article[0],"someowords here");
該函式需要 string.h 標頭檔案支援
Code:- #include<string.h>
長字串的輔助測量方法
Code:- //-----------------012345678901234567890123456789012345678901234567890123456789012
- strcpy(article[0],"Hello everybody My name is Mutoo. I love programming very much!");
- strcpy(article[1],"You can contact me by my E-mail: [email protected]");
- strcpy(article[2],"Or visit my blog: http://blog.csdn.net/cmutoo");