| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
input array of strings
I am trying to get an input of polynomial and put it into an array of strings, but I can't make a condition to exit a loop.
Here is a fragment of my code: void get(istream& ins) { vector <string> a(80); int N=0, i=0; string x; while(cin>>x) // with this condition loop never exits { a[N++]=x; } Thanks for helping. |
|
#2
|
|||
|
|||
|
To do this you'll probably want to set a specific value to be entered to break the loop. So for example if '-1' is read in then the loop should be broken. To do this you may want to read it into a separate variable and test it before putting it in the array if you don't want it to appear there.
Hope this helps, -KM- |
|
#3
|
|||
|
|||
|
input array of strings
Thanks.
Quote:
|
![]() |
| Viewing: Dev Articles Community Forums > Programming > C/C++ Help > input array of strings |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|