Hi i am bilal n i am new here
i need to make a program on Human simulation.......
Well what i need is a code. when i am executing a program like am printing 'x' for infinite many times during execution when the console is printing x infinitely what can i do to stop that and 1 more
i also need a statement that take input from user bu without waiting for user to input or if the user inputs nuffin in 2 secs the program shall proceed ahead .....................
PLZ PLZ PLZ PLZ PLZ PLZ help me i really need buth of those or atleast the latter one.

Recommended Answers

All 6 Replies

Scan for input, and break; when you get some.

In the loop checking for input, set up a counter with clock() and check if it's been two or so seconds, in the loops condition.

Fanx Bu can ya show it in an example that will be more helpin please!

Well i think may be i didn't explained my question clearly
Here it goes again
I need a command or function for which user gets only 2 secs to input a value if he doesn't input any thing in that 2 secs the program proceeds.. In actual the problem is when we want an input form user the execution pauses until or unless the user press any thing from keyboard. But what i need is that program only stops for 2 secs if no one inputs any thing than the program move forward......

Spawn a thread to count two seconds, after that make your tread force '\n' into the keyboard buffer and there you go

Chris

i need to make a program on Human simulation.......
Well what i need is a code.

We don't give code. We give help. You give code.

when i am executing a program like am printing 'x' for infinite many times during execution when the console is printing x infinitely what can i do to stop that and 1 more

I usually press Ctrl-C which stops a program for my operating system.

i also need a statement that take input from user bu without waiting for user to input or if the user inputs nuffin in 2 secs the program shall proceed ahead .....................

C/C++ by definition cannot scan for a single character and continue. Some compilers have added extensions that can do it, but it's rare.

PLZ PLZ PLZ PLZ PLZ PLZ help me i really need buth of those or atleast the latter one.

And never post annoying things in your questions, like the green text and everything after it. It actually makes people want to skip your post.

I am a real newbie so... An example might help if you can please....

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.