simple Array question.

Is there a way to have the user type something into an array and then find out and display how many characters the user input into the array (i guess this would be the size of the array)?
- I am just starting out in c++ so any suggestions are appreciated.
[265 byte] By [frasifrasi] at [2007-11-20 11:13:14]
# 1 Re: simple Array question.
You can introdution all data in a vector (stl,++) and when the user finish to introduce data use vector::size().

vector <typeOfData> vData;
bool bEnd = false;
while(!bEnd) { // while the user input data
vData.push_back(data);
if(data == nodata) bEnd = true;
}

int nData = vData.size();

typeOfData: it is... whats type of data ;)
bEnd: boolean to identifique the end of the getting data.
vData: is the container of data.
data: is the actual data. (I dont know how you get the data)
nodata: data to identifique that the user would not want to introduce anymore data.
nData: number of data stored.

Perhaps I do not understand fine your ask, is this that you are waiting for?
juanpast at 2007-11-10 22:26:16 >
# 2 Re: simple Array question.
Is this a console application or a GUI application?
If console, you can use std::cin to retrieve input from the user and store the retrieved text in an std::string and the use the length member function to get the size of the string.
Marc G at 2007-11-10 22:27:20 >