getchar Questions

7

Solved

Is there a Go function similar to C's getchar able to handle tab press in console? I want to make some sort of completion in my console app.
Jessalyn asked 30/12, 2012 at 20:7

6

I have read about 5-10 different advices how to clear stdin, but none of them suits my needs. The thing is that fflush(stdin) worked perfectly at my computer, but unfortunately it doesn't seem to w...
Metaplasm asked 19/4, 2016 at 9:58

11

I am learning C and I'm using "getchar()" to stop the command windows so I can see the exercises am doing but it just doesn't work. heres a sample: #include <stdio.h> int main() { int valu...
Rite asked 8/9, 2009 at 1:30

9

Solved

I've been working on this for 2 hours and I am stuck... I found the answer online, but that isn't going to help me learn the concept that I'm obviously missing. Prompt: Write a program to copy its...
Shornick asked 7/4, 2014 at 4:5

9

Solved

I'm reading The C Programming Language and have understood everything so far. However when I came across the getchar() and putchar(), I failed to understand what is their use, and more specifically...
Montevideo asked 23/5, 2012 at 13:21

2

Solved

I've wrote this small function to read all the data from stdin. I need to know if this function is POSIX compatible (by this, I mean it will work under Unix and Unix-like systems) at least it work...
Engrain asked 24/11, 2014 at 4:34

5

I want to do user input in python which is similar to getchar() function used in c++. c++ code: #include<bits/stdc++.h> using namespace std; int main() { char ch; while(1){ ch=getchar(); ...
Cadena asked 16/2, 2018 at 5:5

5

So for the up key on the keyboard, I get 27, surprisingly for the down key I also get 27. I need my program to behave differently on the up and down key, and I can't seem to figure it out. I am usi...
Tarah asked 9/3, 2013 at 2:26

9

Solved

I'm reading K&R's The C Programming Language and have become confused on putchar and getchar. I made a program where you enter 10 chars and the program prints them back out to the screen. #inc...
Brookes asked 14/10, 2013 at 19:26

9

Solved

I have just started to learn programming (C) as a hobby, by myself. I'm using K&R. main() { int c; while ((c = getchar()) != EOF) putchar(c); } Verify that getchar() != EOF IS 0 OR 1 I ...
Haunt asked 19/7, 2013 at 12:9

14

Solved

In the next code: #include <stdio.h> int main(void) { int c; while ((c=getchar())!= EOF) putchar(c); return 0; } I have to press Enter to print all the letters I entered with getc...
Garrott asked 25/11, 2009 at 17:19

3

Solved

I'm working through "The C Programming Language" by K&R and example 1.5 has stumped me: #include <stdio.h> /* copy input to output; 1st version */ int main(int argc, char *argv[]) { in...
Hercule asked 9/7, 2013 at 15:39

6

Solved

I'm reading this book: The C Programming Language - By Kernighan and Ritchie (second Edition), and in one of the examples I'm having trouble understanding how things are working. #include <stdio...
Colchicine asked 19/8, 2011 at 9:18

5

Solved

I am currently reading K&R's book and typing in the examples from the first section, and there are a couple of examples such as this: while((c = getchar()) != EOF) { //do something } I am t...
Pericline asked 13/7, 2009 at 11:32

2

Solved

What's the difference between getting a key press with: GetKeyState() GetAsyncKeyState() getch()? When should I use one over the other?
Millymilman asked 21/7, 2013 at 9:10

2

Solved

I need to add a timeout function for getchar() in my program. What do I do so that when my program reaches the instruction getchar(), it will only wait for a certain amount of time for the user t...
Leprosarium asked 16/3, 2011 at 7:20

5

Solved

This code comes from K&R. I have read it several times, but it still seems to escape my grasp. #define BUFSIZE 100 char buf[BUFSIZE]; int bufp = 0; int getch(void) { return(bufp>0)?buf[-...
Picrite asked 14/12, 2011 at 14:0

6

Solved

I am confused about getchar()'s role in the following code. I mean I know it's helping me see the output window which will only be closed when I press the Enter key. So getchar() is basically wait...
Edington asked 9/3, 2010 at 10:8

3

Solved

I am confused by a piece of code found in a function I am studying: char GetCommand( void ) { char command; do { printf( "Enter command (q=quit, n=new, l=list): " ); scanf( "%c", &command...
Pavier asked 4/9, 2010 at 2:2

1

Solved

I'm writing to understand as much as I can of the following program that I tried to compute, because I thought it had some possible application for everyday life. The program goes like this (it's ...
Flattie asked 21/10, 2018 at 10:9

3

Solved

char **query; query = (char**) malloc ( sizeof(char*) ); int f=0; int i=0,j=0,c; while((c=getchar())!=EOF) { if(!isalpha(c)) continue; if(f==1) query=(char**) realloc(query,(i+1)*sizeof(c...
Lao asked 21/1, 2014 at 14:18

6

Solved

I am not able to find the equivalent header file for conio.h in Linux. Is there any option for getch() & getche() function in Linux? I want to make a switch case base menu where the user will...
Chrysalis asked 19/9, 2011 at 9:55

3

Solved

This is a very basic C question, coming from page 18 of Kernighan and Ritchie. I've compiled this very simple code for counting characters input from the keyboard: #include <stdio.h> /* co...
Golem asked 14/2, 2017 at 10:23

1

Solved

I have a very simple code to convert Upper case to lower case: #include <stdio.h> int main() { char c; int i=0; for (i=0;i<10;i++){ c=getchar(); c=c-'A'+'a'; printf("%c\n",c ); ...
Zoniazoning asked 23/6, 2016 at 8:31

5

Solved

I am currently in chapter 1.5.1 File copying and made a program like so: #include <stdio.h> /* copy input to output; 1st version */ main() { int c; c = getchar(); while (c != EOF) { pu...
Cerelly asked 20/5, 2014 at 1:48

© 2022 - 2025 — McMap. All rights reserved.