Im having some trouble with an Array in C++.
See I want to let the user give the program an input in form of a String
, and keep doing it until the user is satisfied. My input is working fine but when i want to store the strings in to an array im running in to some problems. I have to define a size for my array apparently? and is there a way to store the input in 2 or 3 different arrays
(depending on the input, which i sort with some if-statements) of strings, and the print them out?
My code looks something like this now..
string firstarray[10];
string secarray[10];
//The cin stuff here and reading strings from user-input
if(MyCondition1){
for(int x = 0; x<=9;x++){
firstarray[x] = name;
}
if(MyCondition2){
for(int x = 0; x<=9;x++){
secarray[x] = name;
}
Is there a way to skip the 10-limit of an array? could it be like string
firstarray[];
?
std::string
, right? I mean, I don't see ausing namespace
anywhere... – Mr Lister Feb 28 '12 at 14:40