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 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 PostUse
fgets()
. It clears the buffer and places the data into a char* of your choice. There's the input buffer you have total control over.
Jump to PostLet's recap:
hi there)
guys , please tell me - is there any way to check that the standart input is empty or no.
big thanks in advance)There's no portable way to do this without actually blocking for input.
in terms of programming philosophy you're really right.....i even haven't thought …
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.