I'm trying to input multiple strings into an array.
I tried using 2 dimensional array
I know the mistake is right there at cin.getline , but I can't stuff anymore parameters into that. I know you can use a for loop for numbers, but string is different.Code:#include<iostream.h> int main() { const int ROWS=3; const int COLS=20; char array[ROWS][COLS]; cout<<"enter some text: "<<endl; cin.getline (array, ROWS, '\n'); ......
I tried using normal arrays
The "while loop" doesnt work for some reason. I just get this:Code:.... const int MAX=30; char array[MAX]; char indicator ='y'; while (indicator=='y' || indicator =='Y') { cout<<"enter some text: "<<endl; cin.getline(array, MAX, '\n'); cout<<"continue? (y/n)?: "; cin>> indicator; } cout<<array; ...
why does it loop only once??Code:output: enter some text: intput: abc output: continue?(y/n)?: input: y output: enter some text: continue?(y/n)?



LinkBack URL
About LinkBacks



, wasnt done one purpose. After posting in C, i realised "oh wat? this is not C++ forum" hehe