Jump to content
Sign in to follow this  
yeye

Mistake?

Recommended Posts

#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.cpp

H:\lab6\lab6\vuybiu.cpp(11) : error C2117: 'bvbvb' : array bounds overflow

H:\lab6\lab6\vuybiu.cpp(11) : error C2117: 'edr' : array bounds overflow

H:\lab6\lab6\vuybiu.cpp(12) : error C2117: 'cvcvc' : array bounds overflow

H:\lab6\lab6\vuybiu.cpp(12) : error C2117: 'qmuy' : array bounds overflow

H:\lab6\lab6\vuybiu.cpp(13) : error C2117: 'dsgad' : array bounds overflow

H:\lab6\lab6\vuybiu.cpp(13) : error C2117: 'wsd' : array bounds overflow

H:\lab6\lab6\vuybiu.cpp(13) : error C2117: 'ybr' : array bounds overflow

H:\lab6\lab6\vuybiu.cpp(14) : error C2117: 'ddsdfd' : array bounds overflow

H:\lab6\lab6\vuybiu.cpp(14) : error C2117: 'jybrt' : array bounds overflow

H:\lab6\lab6\vuybiu.cpp(15) : error C2078: too many initializers

Error 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

Share this post


Link to post
Share on other sites

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 by 1kHz

Share this post


Link to post
Share on other sites

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....

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...