yeye 0 Report post Posted September 21, 2004 #include<iostream>#include<string>using namespace std;void main(){ string character; int i,j; char array[12][3]={ "bvbvb","edr","wx", "cvcvc","wd","qmuy", "dsgad","wsd","ybr", "ddsdfd","d2","jybrt", "dfefw","eqsq","e5g6y", "fafee","weq","y6", "eedfe","ki7","tyh", "ectct","gtev","8ik", "cwrgw","yvv","rth", "cwechu","ebvy","trh", "gvy7j","bte","trh", "vrtej","rtn","nriut" }; for(i=0;i<12;i++) { for(j=0;j<3;j++) cout<<array[j]<<endl; }}--------------------Configuration: dhtuyb - Win32 Debug--------------------Compiling...vuybiu.cppH:\lab6\lab6\vuybiu.cpp(11) : error C2117: 'bvbvb' : array bounds overflowH:\lab6\lab6\vuybiu.cpp(11) : error C2117: 'edr' : array bounds overflowH:\lab6\lab6\vuybiu.cpp(12) : error C2117: 'cvcvc' : array bounds overflowH:\lab6\lab6\vuybiu.cpp(12) : error C2117: 'qmuy' : array bounds overflowH:\lab6\lab6\vuybiu.cpp(13) : error C2117: 'dsgad' : array bounds overflowH:\lab6\lab6\vuybiu.cpp(13) : error C2117: 'wsd' : array bounds overflowH:\lab6\lab6\vuybiu.cpp(13) : error C2117: 'ybr' : array bounds overflowH:\lab6\lab6\vuybiu.cpp(14) : error C2117: 'ddsdfd' : array bounds overflowH:\lab6\lab6\vuybiu.cpp(14) : error C2117: 'jybrt' : array bounds overflowH:\lab6\lab6\vuybiu.cpp(15) : error C2078: too many initializersError executing cl.exe.vuybiu.obj - 10 error(s), 0 warning(s)APA SEBENARNYA ARRAY BOUND OVERFLOW ITU.DAN KENAPA MASIH JUGA ERROR WALAUPUN TELAH DIGUNAKAN TANDA (" ") UNTUK MENUNJUKKAN BAHAWA ITU ADALAH CHARACTER Quote Share this post Link to post Share on other sites
1kHz 0 Report post Posted September 22, 2004 (edited) ingat: char str[4] = "abc";kalau nak buat array of char string kena mcm ni:char str[3][4] = { "abc", "def", "ghi"}kalau awak nak buat mcm yg awak buat tu, mungkin boleh pakai char array[36][11] atau char array[12][3][11]11 tu ganti dgn panjang 1 char string yg awak nak..nak senang guna string je la, buat apa guna char array (c-string).. Edited September 22, 2004 by 1kHz Quote Share this post Link to post Share on other sites
akuBest 0 Report post Posted September 28, 2004 A'kum... hmm dah lama tak masukk.... ermm betul kata 1khz tu yeye.... dari apa yang ko buat tu, panjang rentetan ko lebih dari saiz yg ko declare. contohnya cenggini, char ayat[3][4] = {"ali","ahmad","minah"};kalo ko tgk, rentetan ahmad ngan minah tu dah lebih dari saiz yg ko declare "4" tu. arap ko paham kot.... Quote Share this post Link to post Share on other sites