我試圖將一些數據存儲在陣列通話holder
,問題是,當我顯示陣列什麼是店它,我不知道什麼是錯的,甚至儘管邏輯似乎適合我。數據來自數組調用sender
我正在使用二維數組在MAX處將其存儲爲5。數據不存儲在陣列中
for (int t = 0; t < strlen(sender) && stop == false; t++){ // stop is the bool that created to break the loop
if (sender[t] != ';'){ // all the data being store in the holder will be separated by ';'
holder[d][t] = sender[t];
}
if (sender[t] == ';') // if the sender at position of 't' number meet ';' then plus one to start store the next data
d++;
if (holder[d][t] == '\0'){ // if it meet the '\0' then exit from the for loop
holder[d][t] = '\0'; // If `;` found, null terminate the copied destination.
stop = true;
}
}
這是發送者陣列"Hello;How;Is;Good Bye"
輸出是
Your holder-----> '
Actual holder---> 'Hello'
是否有d起始值? (在循環之前?) '持有者[d] [t] =發件人[t];' – 2012-02-25 17:58:05
請您能否正確縮進您的代碼片段? – 2012-02-25 17:58:43
@OfirBaruch是的,它初始化爲'0' – Ali 2012-02-25 17:59:03