Getting User Input | C | Tutorial 12

  Рет қаралды 43,154

Giraffe Academy

Giraffe Academy

Күн бұрын

Source Code - www.giraffeacad... This video is one in a series of videos where we'll be looking at programming in c. The course is designed for new programmers, and will introduce common programming topics using the c language.
Throughout the course we'll be looking at various topics including variables, arrays, getting user input, loops, conditionals, pointers, structs, and much more.

Пікірлер: 23
@hubercats
@hubercats 3 жыл бұрын
Hi Mike - Great videos. One comment regarding use of fgets(). You mention that there is an implicit newline. What you don't say, unless I missed it, is that the newline actually consumes one of the 20 bytes of storage you allocated in the name array. I.e., the code you show will really only read the first 19 characters. It does not read 20 and then add a newline. I found this out by testing your code. - Cheers - Jim
@NinaBayutas-pt6yp
@NinaBayutas-pt6yp 21 күн бұрын
Very specific and well explained. Thank you for creating a valuable video like this❤. Pls create more....😊
@strawberrytoffee
@strawberrytoffee Ай бұрын
thank you, this video was very helpful, your teaching is awesome
@studynewthings1727
@studynewthings1727 2 жыл бұрын
much things covered in 12 minutes awesome
@RobertHieger
@RobertHieger 2 ай бұрын
Hi Mike, This is a very instructive video. But I am mystified by one thing. You advocate use of the fgets() function when virtually every onine source I have consulted says that fgets() is deprecated and unsafe. Are these sources wrong? I've been kind of tearing my hair out trying to find a reliabl solution to the problem caused by 2 successive calls to scanf(), which as you mentioned, will leave the newline character in the buffer, causing the next call to scanf() not to work as intended. Is the ue of fgets() permissible in some situations given its status as a deprecated function? I would be interested to hear your take on this. Best, Robert Hieger
@sudalaitech4019
@sudalaitech4019 5 жыл бұрын
What is that %lf ?Please clear my doubt
@ozr2222
@ozr2222 Жыл бұрын
it stands for the data type double
@anonimous8125
@anonimous8125 Жыл бұрын
I don't get how char name is an array that will accept 10 chatacters but suddenly it able to store 10 words in it with just changing the intut function
@Sonic_gummy_bear
@Sonic_gummy_bear 3 жыл бұрын
very true
@Blackilykat
@Blackilykat 2 жыл бұрын
a little issue i had: i was using this line scanf("%c", &characterr); and it just skipped to the next one. to avoid that put a space before the %c scanf(" %c", &characterr); for some reason it fixes it
@lilyscarlet2584
@lilyscarlet2584 2 жыл бұрын
scanf uses spaces as a delimiter of some sort to figure when to get the next thing. so if you have multiple scanf and there is no space in between it will not move on.
@sal4567
@sal4567 Жыл бұрын
Try using fflush(stdin) after every scanf
@erilleshi1958
@erilleshi1958 6 ай бұрын
Its 3:23 am I’ve been scrolling everywhere to find out why does it skip when I put everything together and I just read ur comment ur the goat bro it worked
@Tatsumaki9238
@Tatsumaki9238 3 жыл бұрын
sorry i'm learning c from another guy but i have subscribed to this channel.soi need help about somthing so please help me.so the thing is i was practicing c on codeblocks ,practicing scanf("%d %d",&a,&b); for user inputed addition of 2 numbers but when i built and ran it it didn't take the values and showed a addition of 2 huge garbage values. so how can i make it take both numbers? bellow i gave the code i wrote: #include int main() { int a,b,c; printf("Enter Two Values "); scanf("%d %d",&a,&b); c=a+b; printf("The Addition of Two Values %d And %d is %d"); return 0; } Help sir
@user-nj3ib8so1h
@user-nj3ib8so1h 3 жыл бұрын
I'm 6 months late but you forgot to mention the variables in 2nd printf statement 😇
@abdikaliqosman8891
@abdikaliqosman8891 2 жыл бұрын
tell me that guy please
@MuslimMan377
@MuslimMan377 2 жыл бұрын
printf("The Addition of Two Values %d And %d is %d", a , b , c); you forgot to mention the *a, b, c*
@brendongong2461
@brendongong2461 2 жыл бұрын
how would i take in user input that includes new lines (i.e. multi-line input)
@brendongong2461
@brendongong2461 2 жыл бұрын
thanks for the video btw!
@schlopping
@schlopping 2 жыл бұрын
take input in a loop
@Anonymous-yb7nl
@Anonymous-yb7nl 3 жыл бұрын
Hey bro I copied this code and run it but it doesn't allow you to enter the grade // strings char name[10]; printf("Enter your name: "); fgets(name, 10, stdin); printf("Hello %s! ", name); // ints int age; printf("Enter your age: "); scanf("%d", &age); printf("You are %d ", age); // chars char grade; printf("Enter your grade: "); scanf("%c", &grade); printf("You got an %c on the test ", grade); // doubles double gpa; printf("Enter your gpa: "); scanf("%lf", &gpa); printf("Your gpa is %f ", gpa);
@unstablethermalpaste3366
@unstablethermalpaste3366 2 жыл бұрын
one curious question... Are you really always coding and sitting like that? XD
@nuelzemudio883
@nuelzemudio883 3 ай бұрын
Lol. Why?
Building a Basic Calculator | C | Tutorial 13
5:55
Giraffe Academy
Рет қаралды 22 М.
why are switch statements so HECKIN fast?
11:03
Low Level
Рет қаралды 411 М.
Officer Rabbit is so bad. He made Luffy deaf. #funny #supersiblings #comedy
00:18
Funny superhero siblings
Рет қаралды 15 МЛН
Programming Languages DON'T MATTER | Let's Rant!
10:05
Giraffe Academy
Рет қаралды 44 М.
Master Pointers in C:  10X Your C Coding!
14:12
Dave's Garage
Рет қаралды 312 М.
Why You Shouldn't Nest Your Code
8:30
CodeAesthetic
Рет қаралды 2,7 МЛН
Learn Any Programming Language In 3 Hours!
22:37
Code With Huw
Рет қаралды 430 М.
Object-Oriented Programming is Embarrassing: 4 Short Examples
28:03
Be Careful When Using scanf() in C
12:22
NeuralNine
Рет қаралды 129 М.
you will never ask about pointers again after watching this video
8:03
Just enough C to have fun
39:29
Kay Lack
Рет қаралды 50 М.
How to use scanf with fgets
8:59
CodeVault
Рет қаралды 33 М.