How do I cin chars into an array and stop when the console reads a specific char

What I want to do is to input characters into an array and stop the inputs and set the array length once a certain character is inputted. I'm unsure on how I can do this without specifying the array length first. What I tried out was a for loop at first, but to input everything into their respective position on the array, an array would have to exist beforehand.

Thanks for reading. Happy New Year for those of you who have it tonight.

I have something like this so far:
1
2
3
while (arr[i] != -1) {
        cin >> arr[i];
    }
Sorry, but you can define the size of the array after inputting data into it. You have to declare the size then input data in. The way around this is using vectors and using push_back which will allow you to continue adding data to the vector until your character appears.

Here's the site for vectors.
http://www.cplusplus.com/reference/vector/vector/
Topic archived. No new replies allowed.