| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
assigning values to variables usin cin in c++
is not working for me in case i press ctrl_z.
Having filled a text data file inside a do while, i press ctrl_z to end the process. Than i try to assign value to a variable using cin but i cant because of the ctrl_z i had pressed before. Is there a way to clean the data extraction from the "end of file" ? |
|
#2
|
|||
|
|||
|
Can you paste the code?
Question is not clear. Why do you want to press Ctrl-Z.This combination will break a runing process. |
|
#3
|
|||
|
|||
|
you shouldnt be using Ctrl-Z to end the Do while. you should have something going up (such as x++) which should cause it to end.
i think thats what your going on about... |
|
#4
|
|||
|
|||
|
Yes i'm afraid i expressed my problem
very unclearly.
The reason i used ctrl_z is i was inserting data into a text file from within a do while loop. There is no other way to stop it but using the ctrl_z key combination. What i needed to do than was cin.clear() to enable the cin to continue working for me. I'm sorry for displaying my problem in an unordered way. And thanks a lot ! |
|
#5
|
|||
|
|||
|
pssheba: I got what you are trying to say. I am paraphrasing in my on words. Correct me if I'm wrong:
You are using a Do-while loop to ask a user for imputs. Then at arbitrary time, you wish your program to stop taking input from the end user. For this you are taking help of Crtl-Z combination. Is this true? In such case , you can ask question from user,whether he is interested in supplying inputs or not? In case of yes, person cin operation, else , use " exit(1); " statement to shut down the program or "break;" for coming out of the loop but continue with execution process. Probably, the input taken by "cin" statement is being redirected to a file. That is, cin>>variable; cout>> variable >> file; |
![]() |
| Viewing: Dev Articles Community Forums > Programming > C/C++ Help > assigning values to variables usin cin in c++ |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|