So I'm trying to have the user enter strings that will be put into an array with the maximum size of 50 strings. Whenever the user enters "stop", I want the loop to stop and the array to cutoff there.
I then want to read the array back to the user. I tried running this and got a really weird error. Can someone explain to me why this doesn't work and how I would fix it? Thanks.
int main(int argc, const char * argv[]){
string array[50];
// Get's inputs for array
for(int i = 0; i < 50; i++){
cout << "Enter string: ";
getline(cin, array[i]);
if(array[i]== "stop"){
array[i] = "\0";
break;
}
}
// Reads inputs from array
for(int i = 0; i < sizeof(array); i++){
cout << array[i] << "\n";
}
return 0;
}
I don't know why I'm getting down voted so hard?