C Programming Tutorial - 66: The getchar() and putchar() Functions

preview_player
Показать описание
In this tutorial we'll see how we can use the getchar() function to receive single character input and how we can display characters using the putchar() function.
Рекомендации по теме
Комментарии
Автор

Thanks! In the first second of your video, I understood how they are used by how you arranged the program. I cannot express how terribly they explained it at my college.. 

blazekazama
Автор

This is why I love Indians. Great food, Konnakol and programming help.

bencilbusher
Автор

8 years later still watching this video

adnanaadil
Автор

#include <stdio.h>
main()
{
 char ch;
 printf("Enter a character:");
 ch = getchar();
 printf("The character entered is:");
putchar(ch);

}

Here is the code

gudukasa
Автор

In c=getchar() it is easier to take input of characters more than 1 bit like a sentence and print it using putchar(c). All u have to do is instead of declaring char C declare int c.

AbhishekSharma-xmfi
Автор

Getchar is to get a first character from a stream of characters. Not from user input. To be more precise.

Sobioytccc
Автор

putchar does not add a null terminator character (\0) because tis a *char* as the name suggests, printf/puts does because those are *string* functions, not *char* functions. Some things are easier to do by using single chars rather than strings because the null terminator may or may not cause problems by string I mean an aray of characters, arrays decay into constant pointer variables.

RecycleBin
Автор

Your tutorials are amazing, I understand everything because of you, bless u,

anng
Автор

Simply well explained. Thank u bradr
😊

kavinj
Автор

9 Years later still watching this video

diprajrane
Автор

Thank you very much. You are a genius. 👍👍🔝🔝

vakhariyajay
Автор

ch should be an int to check for EOF, which is a negative value.

GrandNecro
Автор

Should pressing enter after getchar function be necessary? How can I make it without pressing enter? Do I need new library?

bartlomiejodachowski
Автор

I been trying to use visual studio to run this code but sadly it doesn't work. What program are you using?

jacksmack
Автор

Sir, is it possible to give inputs with out scanf command

adsaikiranreddy
Автор

We can do the same using scanf() and printf(). So is there a difference between their usage based on your example?

fahad
Автор

Why would i use getchar and putchar ? Like i understand what they are doing but why would i use them and i have printf scanf etc.

alex
Автор

Is this the syntax for putchar() and get char()

supreetak
Автор

Very nice! Thank you. What IDE are you using? I am having a problem running this short example in Eclipse on a Windows 7 machine.

Bill

billstanard
Автор

very bad you didnt talk about how the buffer stores chars

alxbudn