C user input ⌨️

preview_player
Показать описание
C how to accept user input scanf fgets tutorial example explained

#C #user #input

char name[25]; //bytes
int age;

printf("\nWhat's your name?");
//scanf("%s", &name);
fgets(name, 25, stdin);
name[strlen(name)-1] = '\0';

printf("How old are you?");
scanf("%d", &age);

printf("\nHello %s, how are you?", name);
printf("\nYou are %d years old", age);
Рекомендации по теме
Комментарии
Автор

#include <stdio.h>
#include <string.h>

int main(){

char name[25]; //bytes
int age;

printf("\nWhat's your name?");
//scanf("%s", &name);
fgets(name, 25, stdin);
name[strlen(name)-1] = '\0';

printf("How old are you?");
scanf("%d", &age);

printf("\nHello %s, how are you?", name);
printf("\nYou are %d years old", age);

return 0;
}

BroCodez
Автор

This was a splendid lesson on user input in C. Thanks a ton.

annoyingprecision
Автор

Great production quality with your videos!

TheScissorunner
Автор

i like that u mention the gap in knowledge at certain parts

eeneemeenee
Автор

fgets(); Which autocomplete do you use for that?

ShStepan
Автор

noice, the string format also doesn't seem to advanced, great teaching bro

not_pockchan
Автор

when i press run it direct to output and not terminal. how to run it??

nem
Автор

I have an issue where when i run the code, power shell will run in the terminal but I won't see the print line so "How old are you?", instead of seeing the line right away. a new cmd window will pop out and display "How old are you?", then I will have to type the age, then when I type the age, the new window closes and then the question "How old are you?" is written in the terminal. then I have to re-enter the age and then it shows the message You are 21 years old. How can I fix the new window popping out? I did go on code runner to checkmark for the terminal.

PektraNao
Автор

how can run in the black console like visual studio ??

thiemhoang
Автор

Hi bro. I've been watching Java tutorial from your series only.Please help me with the setup of Java in Visual Studio Code
Also are you planning any series on android development ??

harshitpandit
Автор

can you not just do scanf ("%s%s", &nameF, nameL) instead of using fgets?

rezuwankabir
Автор

Why vscode? Why not dev-c++, vs19 or codelite?

aditya_asundi
Автор

printf("Random comment1.2");

vega_yy
Автор

I asked you a question that Which language is best for making mobile app than can control robots (Both iphone and android) ? Pls reply sir 🙏

sashaktyadav
Автор

wazzup bro code!!! im new to the community!!!

Onestonedbake
Автор

he scanfs the string with an & and it works? how?

big_
Автор

am not 21 anymore but i pretend i still am!

Crimera
Автор

how can run input in mac os, because it isn't like your video.

khahanguyen
Автор

oh my god c is not like java at all lol

engirckt
Автор

I asked you a question that Which language is best for making mobile app than can control robots (Both iphone and android) ? Pls reply sir 🙏

sashaktyadav