Questions tagged [input-buffer]

Anything related to input buffers and correlated techniques, i.e. memory areas used as temporary storage for information read on input. Input buffering is usually used to increase the efficiency of the input operations.

Anything related to input buffers and correlated techniques, i.e. memory areas used as temporary storage for information read on input. Input buffering is usually used to increase the efficiency of the input operations.

44 questions
7
votes
1 answer

Can fseek(stdin,1,SEEK_SET) or rewind(stdin) be used to flush the input buffer instead of non-portable fflush(stdin)?

Since I discovered fflush(stdin) is not a portable way to deal with the familiar problem of "newline lurking in the input buffer",I have been using the following when I have to use scanf: while((c = getchar()) != '\n' && c != EOF); But today I…
Jugni
  • 255
  • 5
  • 12
5
votes
2 answers

How to read terminal's input buffer immediately after keypress

I want to read arrow keypresses in my c program and replace them(immediately in the terminal itself) by some other string. I am trying to implement the bash history functionality as in unix terminals. I wrote this code. int main(int argc, char…
bytestorm
  • 1,411
  • 3
  • 20
  • 36
4
votes
0 answers

Clear speech input buffer Swift - Speech Framework

I'm following this Apple Sample Code and was wondering how it would be possible to clear the input buffer (ie. result in this case), so that the dictation restarts once a word has been said. For example: When a users says words, they are added to…
WiseOlMan
  • 926
  • 2
  • 11
  • 26
4
votes
1 answer

scanf() and clear input buffer in one function in C?

I have the following idea: I have a function to clear the input buffer: void clear_inputBuffer() { char c; while ( (c = getchar()) != '\n' && c != EOF); } Instead of writing for every input scanf("%d", &selection); clear_inputBuffer(); I…
David H.
  • 47
  • 1
  • 5
4
votes
3 answers

Read two characters consecutively using scanf() in C

I am trying to input two characters from the user t number of times. Here is my code : int main() { int t; scanf("%d",&t); char a,b; for(i=0; i
coder_r
  • 90
  • 2
  • 11
4
votes
2 answers

how to handle the input buffer in c

I'm new to c programming and I'm facing this problem with my program I have a loop that gets a char form the input buffer while(c = getchar()){ if(c == '\n') break; if(c == '1') Add(); if(c == '2') getInput(); // this is where the…
3
votes
3 answers

Why the "MediaCodec CodecException" in "queueInputBuffer" only happen on Android API 29?

Basic Info targetSdkVersion 28 Goal: The objective of the class is to resize a video before sending to my server. Problem: The app crashes only on API 29, whether with real devices or using AVD. For example, the code works fine on Pixel 2 API 28,…
3
votes
1 answer

Java input buffer and do-while loop behavior (why does it check first character 3 times?)

I have been learning Java with Oracle’s “Java A Beginner’s Guide”, and was having trouble understanding an example program from the book about the input buffer and do-while loop. This example is about a number guessing program. It’s designed to…
2
votes
1 answer

How to get the input action which is performing?

I'm learning the new input system and I'm looking for something like this: if(anyInputActionIsPerformed) { return thatInputAction; } What I'm trying to do is to get the name of the current input action so I can save it in my input buffer for…
Truofan
  • 21
  • 2
2
votes
1 answer

forcing the buffer to clear in scanf

i have a problem with scanf and input buffer in my program. first i ask the user for input : char someVariable; printf("Enter text: "); scanf(" %c",&someVariable); and then i have a loop that goes over the input one char at a time in scanf until…
DarkLeader
  • 589
  • 7
  • 17
2
votes
0 answers

Read UART transmision Input buffer in Matlab

I'm trying to make a serial communication between two ESP8266 Wifi chips. To start, I tried sending a sample data 10 times in a for loop. Here is the code: Transmiter: for Packets = 1 : 10 SendData(client,Data(Packets)); end Receiver: Packets =…
Mehran
  • 307
  • 1
  • 3
  • 15
2
votes
1 answer

Perl IPC::Run3: How to emulate a pty for stdin to child process?

This is a follow up question to IPC::Open3 and determining if child is waiting for input though they admittedly are not related. Take the following sample code: use strict; use warnings; use IPC::Run3; sub foo { my $cmd = shift; my $CH_IN =…
Speeddymon
  • 496
  • 2
  • 20
2
votes
1 answer

Why inside a loop, scanf() with %d does not wait for the user input in case it received an invalid input previously?

I am using what scanf() returns when it gets what is expects or when it doesn't. What happens is it gets stuck in thewhile()` loop. To my knowledge test = scanf("%d", &testNum); returns a 1 if it receives a number and a 0 if not. My…
bubba
  • 23
  • 2
2
votes
1 answer

C++, How cin reads from input buffer?

CS student just starting out with C++ and I'm having difficulty understanding how cin and getline() read in data. string str_1 = ""; cin >> str_1; // User enters "John(Enter)" Its my understanding that cin >> will look in the input buffer…
RaSedg
  • 111
  • 1
  • 10
2
votes
1 answer

file saving on android

I am making a xml file and saving it on my device code follows HttpClient httpclient = new DefaultHttpClient(); HttpPost httppost = new HttpPost("http://xx:xx:xx:xx:yy/LoginAndroid.asmx/login"); httppost.setEntity(new…
A J
  • 4,542
  • 5
  • 50
  • 80
1
2 3