I’m trying to store some data in the array call holder and the problem is that when I display that array nothing being store in it and I don’t know what is wrong even though the logic seem to be right for me. The data is coming from an array call sender I’m using two dimension array to store it up to 5 at MAX.
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;
}
}
This is the sender array "Hello;How;Is;Good Bye"
The output is
Your holder-----> '
Actual holder---> 'Hello'
I don’t understand why you’re not allowed to use
break. Maybe you could clarify the objective of the exercise? Otherwise, maybe this code solves your problem? I would normally have used another technique, but since you said that you’re not allowed to usebreak…