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.
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...
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...
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...
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...
2
Solved
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();
...
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...
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 ...
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...
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...
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?
2
Solved
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...
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...
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 ...
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...
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...
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...
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 );
...
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...
1 Next >
© 2022 - 2025 — McMap. All rights reserved.