help: cin>> in while loop , it reads keyboard only once
Hi!
I'm entering data in array using while loop, the problem I'm getting is that it only asks me to enter data only once, it never repeat asking me to keep on entering data. I'm just using simple while loop code with cin command while (y < 5) {cout<<"Enter the "<<z<<"th word:\n"; z++; cin>>ziword; array[y] = ziword; y++; } How to make sure that it asks me to enter data in all five steps?Is it the problem with cin command? |
Quote:
It is asking me to enter data in all five steps !!!! Code:
#include <iostream> |
[QUOTE=anishakaul;3894087]I tried the below program, its working absolutely fine, what's the problem ?.
Maybe it's a compile problem, or the functioning of my windows xp. Because I was using codeblock and it asks me to enter data only once, and then it prints Enter the 1th word: kachiri 4246726Enter the 2th word: 4246726Enter the 3th word: 4246726Enter the 4th word: 4246726Enter the 5th word: 4246726 Process returned 0 (0x0) execution time : 3.843 s Press any key to continue. When I use Dev-C++ it asks me to enter data only once and then the screen disappears, which compiler are you using? Cheers, Stefano |
Quote:
I can't guide anything regarding the compilers used on windows, Its been 6 years since I last worked on windows !!! May be you should ask this on some windows forum . |
Ok thanks, let me try it on Linux
|
Did you want to enter numbers or words? I ran this on windows and got the same behaviour you described, but after changing the declaration of zi word to
Code:
string ziword; |
All times are GMT -5. The time now is 11:32 PM. |