Skip to main content
Filter by
Sorted by
Tagged with
2 votes
2 answers
109 views

How Does input Buffer actually works in C++?

#include<iostream> #include<cstring> using namespace std; int main(){ string name; int age, Rollno; cin >> age; cin >> Rollno; cin.ignore(); getline(...
M Said's user avatar
  • 23
2 votes
0 answers
66 views

Why does reading input sometimes skips newline character when trying to clear input buffer?

When I input an odd number of characters it works as expected, but when an even number of characters is entered it waits for user input inside of the .clearBuffer procedure. I am using NASM on Windows....
user20694960's user avatar
2 votes
1 answer
2k views

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 ...
Truofan's user avatar
  • 21
1 vote
0 answers
315 views

Cannot get reset_input_buffer() function to work at all in Pyserial 3.5. Does anyone have any idea what may be happening?

I am trying to simulate a communication protocol where I am following a pattern, so I constantly loop though looking for the same set of characters to reply information. I'm using an RS-232 adapter ...
Claudio Rodriguez's user avatar
0 votes
1 answer
1k views

When reading from /dev/tty, what is happening in input and keyboard buffer?

I am playing with the following two code snippets // Snippet1 in C #include <stdio.h> int main(){ FILE * fp = fopen("/dev/tty", "r"); int c = getc(fp); printf(&...
Steve Lau's user avatar
  • 914
0 votes
2 answers
143 views

How does this clear the input buffer?

I found this code that clears the input buffer, but I don't really understand how it works. Can anybody explain it in a simple way? do{ fgets(string,LENGTH,stdin); } while (strlen(string) > 0 &...
Gio Bur's user avatar
  • 15
0 votes
0 answers
496 views

Catch Ctrl+D after having read some input

I'm trying to write a program that works like a UNIX terminal. So when Ctrl+D is pressed, it should exit. I'm reading input using: char input[BUFFER_SIZE]; read(0, input, BUFFER_SIZE) I'm also ...
Maifee Ul Asad's user avatar
0 votes
1 answer
213 views

input buffer while creating multiple objects using for loop in java

I want to create multiple objects using for loop in java but this code is not showing proper output, I can take all inputs properly but output is not shown by the program for the input taken for arr[i]...
Santosh Bhatt's user avatar
4 votes
0 answers
911 views

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 ...
WiseOlMan's user avatar
  • 926
3 votes
3 answers
4k views

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. ...
Mike Casan Ballester's user avatar
1 vote
1 answer
77 views

How to select which one to show in case of dual video in .mp4 file?

I'm using surfaceView where i'm rendering the video. I have a .mp4 file with video/hevc and video/avc. I made two threads such that they are extracted, decoded and rendered to the surface though the ...
Coder7711's user avatar
0 votes
2 answers
283 views

Problems with cin.getline() not accepting input

I am using cin.getline() to store user input in a character array, and attempting to parse input to only allow numbers ranging from 1 to 4 to be entered. Things work fine under a specific set of ...
user avatar
2 votes
1 answer
251 views

How do I clear input buffer after a failed 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); Then I ...
DarkLeader's user avatar
3 votes
1 answer
574 views

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 ...
Jim Anderson's user avatar
4 votes
1 answer
1k views

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 ...
David H.'s user avatar
0 votes
0 answers
148 views

Thread 6: EXC_BAD_INSTRUCTION (code=EXC_I386_INVOP, subcode=0x0)

I am reading bytes from Data. But am getting a crash after first iteration of while loop. Note: This is not index out of bounds issue. func readData(data: Data) { if isPacketRecieved == ...
iAnurag's user avatar
  • 9,356
0 votes
0 answers
355 views

C++ with menu system: How to eliminate input buffers when pressing arrow keys

I was able to make a program that has a menu on it. At first, the program is running smoothly. The problem starts to appear when, at a certain point in the program, the user starts inputting something ...
Ryon's user avatar
  • 23
1 vote
1 answer
2k views

While loop skips the first `fgets()` on second iteration [duplicate]

I know questions like this get asked all the time, and I have read several, however, I never use scanf() in my code like all the other ones, so I cannot find a comparable question. I don't know why ...
Dan's user avatar
  • 437
1 vote
0 answers
672 views

Asynchronous input in MASM assembly language

I have a project of making a stop watch in assembly language using masm. The stop watch starts on program startup and continues on. I want to implement feature like stop,pause and play. I can't ask ...
Syed Ahmed Jamil's user avatar
0 votes
0 answers
188 views

Can't clear cin. Stuck at input

When cin fails, it fails for ever. I.e. I can't read anything afterwards and cin.fail() always returns true, no matter how I try to clear it. Minimal code to recreate: #include <iostream> ...
iBug's user avatar
  • 36.9k
0 votes
0 answers
88 views

regarding clearing the input buffer in c [duplicate]

I have this code, a program to take an integer from a user that's negative, if not trap them in a loop until they enter a negative integer. I have this part down, however, how could i clear the input ...
David Scarpa's user avatar
-4 votes
3 answers
183 views

is clearing the buffer by assigning char * buffer to '\n' while getting user input inside a loop in c wrong? [closed]

I tried to solve the problem* I face when I want to get user input inside a loop. edit *: problem is this -> clearing buffer to read next input. is this error-prone? #include <stdio.h> ...
zuxi's user avatar
  • 3
-2 votes
3 answers
332 views

How to clear input buffer when scanning values from a text file in C?

#include <stdio.h> #define MAX_TITLE_SIZE 20 #define MAX_BOOKS 10 struct Book { int _isbn; float _price; int _year; char _title[MAX_TITLE_SIZE + 1]; int _qty; }; void clear(...
mincedMinx's user avatar
2 votes
0 answers
195 views

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 ...
Mehran's user avatar
  • 317
2 votes
1 answer
536 views

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::...
Speeddymon's user avatar
0 votes
2 answers
2k views

How to know the input buffer of the serial port has information, in C#?

I am building a program in C# to be used in one of my course at a college to demonstrate how Asynchronous connections work using RS-232 and two computers connected together. My course is not about ...
DonPandon's user avatar
-1 votes
2 answers
313 views

what do modifiers like whitespace do in scanf?

#include<stdio.h> void main() { char a,b; printf("enter a,b\n"); scanf("%c %c",&a,&b); printf("a is %c,b is %c,a,b"); } 1.what does the whitespace in between the two format specifiers ...
user avatar
2 votes
1 answer
493 views

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 ...
bubba's user avatar
  • 23
0 votes
2 answers
971 views

AudioTrack not working, there is no sound

can you check why is my Audiotrack not working, i do have a buffer in and out to the audiotrack, it should be able to work. public class MainActivity extends AppCompatActivity { private ...
Bowie Chang's user avatar
1 vote
1 answer
127 views

C programming, Can anyone explain this?

#include <stdio.h> int main() { int c; while ((c = getchar()) != EOF) { if (c == '\t') printf("\\t"); else if (c == '\b') printf("\\b"); ...
user6723034's user avatar
0 votes
0 answers
443 views

No input buffering and flush stdin sometimes clears one input character (c++, windows)

Issue is related only to Windows. I am using visual studio 2012 compiler (vc11). I would like to read few lines (character by character) from input file (which is redirected as stdin). But after ...
piotrp's user avatar
  • 324
0 votes
0 answers
74 views

Present message and prompt re-enter into array if too many characters "out of bounds" entered into an array

I just can't figure it out. I'm not allowed to use the string library, first of all. But, I want the user to enter their major into a char array, but if they enter too many (runs into input buffer), ...
Quadruckus's user avatar
2 votes
1 answer
398 views

C++, How cin reads from input buffer? [duplicate]

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 ...
RaSedg's user avatar
  • 111
5 votes
2 answers
4k views

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. ...
bytestorm's user avatar
  • 1,521
4 votes
3 answers
8k views

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<t; i++) { ...
coder_r's user avatar
  • 90
0 votes
1 answer
523 views

Line feed ending getchar() loop prematurely

I have a problem that I cannot find an actual solution after searching for about half a day. In this program, I have to fill an array of structs with customer information. I also have to do a couple ...
Jesse Upchurch's user avatar
1 vote
2 answers
7k views

How does input buffering work in C++

Here is a code snippet. I'm confused as to how the buffering internally works. while(true) { cout << "Enter a character: "; cin.ignore(3, '\n'); ch = cin.get(); // ch is ...
Chaitanya's user avatar
  • 3,459
7 votes
1 answer
4k views

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 = ...
Jugni's user avatar
  • 255
2 votes
1 answer
663 views

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"...
A J's user avatar
  • 4,632
2 votes
2 answers
2k views

how to parse from file after parsing from string?

My bison / flex parser start by reading input from a file: FILE *myfile = fopen(file.c_str(), "r"); yyin = myfile; yyparse(); At some point after that, it reads and parse input from a string in ...
mhmhsh's user avatar
  • 161
4 votes
2 answers
9k views

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(...
Abdullah Al-Hatem's user avatar
1 vote
4 answers
8k views

getchar not working in switch case (c)

Using a very simple calculator program that prompts a user for an operation to perform, followed by a prompt for two integers on which to perform this operation. The program is supposed to loop after ...
Stumbler's user avatar
  • 2,134
0 votes
3 answers
2k views

SQL Server: Query SysProcesses and InputBuffer

I am trying to pull the input buffer data (DBCC INPUTBUFFER(@SPID)) for each record returned for a database when querying the SYSPROCESSES table. I am interested to hear if there is a better way to ...
jon3laze's user avatar
  • 3,196
0 votes
2 answers
592 views

Pre-populating input in Java console

I'm making a console-based Java/Groovy application that does a lot of find/replaces in text files. If, say, the program knows you replaced foo with bar last time, it should by default know you ...
Drew Reagan's user avatar
0 votes
1 answer
1k views

C++ cin keeps skipping

I am having problems with my program. WHen I run it, it asks the user for the album, the title, but then it just exits the loop without asking for the price and the sale tax. Any ideas what's going on?...
user69514's user avatar
  • 27.5k