Trying to work out how to use eof to read in characters to a dynamic array from console.

I created my own string class which uses dynamic char arrays to store data.

the problem is, i need to add a function which will receive input from the console, and store that into my array.

but as i don't know how many characters the user will enter, i have been trying to work out a way to store some of their input, increase the array, store more input, until all the input is stored.

my teachers have referred me to ios::eof however i have been unable to work out how to implement this. and doing a google search gives me lots of information about eof when using it with files, but i have been unable to find how to use it with cin / cin.getline related functions.

so i would love some info on how to achieve my desired results of storing the user input without needing to use a temporary array that can store up to 10000 characters
You can use array::size(). It works almost the exact same way as string::size() and vector::size(), if not the exact same. Once you've determined the number of inputs from the user, you'll need a growth factor function (people like to use the golden ratio).
Topic archived. No new replies allowed.