hi there)
guys , please tell me - is there any way to check that the standart input is empty or no.
big thanks in advance)
vedro-compota
33
Posting Whiz
Recommended Answers
Jump to Postis there any way to check that the standart input is empty or no.
There's no portable way to do this without actually blocking for input. What OS and compiler are you using, and why do you think you need that behavior?
Jump to PostI would say that you need to test for what the user has done. Not for what he hasn't done. The functions that use stdin take care of initializing the stdin buffer. Your job is to check what the user has put into the buffer after your function calls for …
Jump to PostIt's not the callee's job to clean up after the caller. I think that mainmenu() should simply expect the stream to be in a usable state, and if the caller fails to meet that expectation, it will need to handle erroneous processing by mainmenu().
Jump to PostI was playing with the code provided by 'hkdani' and the mere idea that 'stdin' uses a char pointer '_ptr' to point to the data in the buffer, I tried to compile the following code(just for fun, cause it's been itching me):
#include <stdio.h> #include <string.h> …
Jump to Postwhat's that extra byte? does anyone know?
Perhaps a sentinel, or some kind of bookkeeping data. It might even be part of the CRLF combination if you're on Windows and the implementation uses a move-to-rear strategy of removal.
Ultimately, the problem is that you're using implementation internals without understanding …
All 27 Replies
hkdani
39
Posting Pro in Training
Narue
5,707
Bad Cop
Team Colleague
vedro-compota
commented:
+++
+3
hkdani
39
Posting Pro in Training
vedro-compota
33
Posting Whiz
vedro-compota
33
Posting Whiz
D33wakar
36
Posting Whiz in Training
hkdani
39
Posting Pro in Training
vedro-compota
commented:
++++++++
+3
vedro-compota
33
Posting Whiz
hkdani
39
Posting Pro in Training
Narue
5,707
Bad Cop
Team Colleague
vedro-compota
33
Posting Whiz
Narue
5,707
Bad Cop
Team Colleague
vedro-compota
33
Posting Whiz
hkdani
39
Posting Pro in Training
vedro-compota
33
Posting Whiz
Narue
5,707
Bad Cop
Team Colleague
hkdani
39
Posting Pro in Training
vedro-compota
33
Posting Whiz
WaltP
2,905
Posting Sage w/ dash of thyme
Team Colleague
vedro-compota
commented:
+++++
+3
vedro-compota
33
Posting Whiz
WaltP
2,905
Posting Sage w/ dash of thyme
Team Colleague
vedro-compota
33
Posting Whiz
WaltP
2,905
Posting Sage w/ dash of thyme
Team Colleague
vedro-compota
33
Posting Whiz
D33wakar
36
Posting Whiz in Training
vedro-compota
commented:
+++
+3
hkdani
commented:
A willing and inquisitive mind that probes the depths to add knowledge. Gems of wisdom will be gleaned from this source.
+6
Narue
5,707
Bad Cop
Team Colleague
D33wakar
commented:
thanks!
+4
hkdani
39
Posting Pro in Training
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.