C user input ⌨️
HTML-код
- Опубликовано: 12 июн 2024
- C how to accept user input scanf fgets tutorial example explained
#C #user #input
char name[25]; //bytes
int age;
printf("
What's your name?");
//scanf("%s", &name);
fgets(name, 25, stdin);
name[strlen(name)-1] = '\0';
printf("How old are you?");
scanf("%d", &age);
printf("
Hello %s, how are you?", name);
printf("
You are %d years old", age); - Наука
#include
#include
int main(){
char name[25]; //bytes
int age;
printf("
What's your name?");
//scanf("%s", &name);
fgets(name, 25, stdin);
name[strlen(name)-1] = '\0';
printf("How old are you?");
scanf("%d", &age);
printf("
Hello %s, how are you?", name);
printf("
You are %d years old", age);
return 0;
}
how about the birthdate?
How about this
#include
int main() {
char input1[100];
char input2[100];
printf("Input 2 (without space): ");
scanf("%s", input2);
printf("Input 2: %s
", input2);
// Clearing input buffer
while (getchar() != '
');
printf("Input 1 (with space): ");
scanf("%[^
]", input1);
printf("Input 1: %s
", input1);
return 0;
}
My friend using that code
This was a splendid lesson on user input in C. Thanks a ton.
i like that u mention the gap in knowledge at certain parts
Great production quality with your videos!
Thanks for the tutorials bro!
Very useful, cheers mate.
Very simple and good.
Thank You!!
ur the best :)
Great
amazing bro👍
fgets(); Which autocomplete do you use for that?
Bro❤️
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 🙏
Python with Kivy framework could work
❤❤❤❤
noice, the string format also doesn't seem to advanced, great teaching bro
❤
when i press run it direct to output and not terminal. how to run it??
legend
DONE❤
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 ??
how can run in the black console like visual studio ??
cmd in windows
yoooooooooooo
early!
thx for noticing!
wazzup bro code!!! im new to the community!!!
how can run input in mac os, because it isn't like your video.
Why vscode? Why not dev-c++, vs19 or codelite?
more people are transitioning to vscode
lmao and here I am using notepad
Those are trash
can you not just do scanf ("%s%s", &nameF, nameL) instead of using fgets?
he scanfs the string with an & and it works? how?
if you dont put it it will modify the pointer so...
@@redemedy8602 no not at all. with int or char variables you use & to get their address aka get a pointer to them and change the value at which the pointer points. if you assign a pointer to a pointer with & you will only change the pointer (you will change where it points to) and that will cause an error
It works because &array is equal to array in C, if he was using a pointer to a buffer allocated with malloc it would crash
am not 21 anymore but i pretend i still am!
printf("Random comment1.2");
:((
oh my god c is not like java at all lol
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 🙏