Getting User Input | C | Tutorial 12

preview_player
Показать описание

Throughout the course we'll be looking at various topics including variables, arrays, getting user input, loops, conditionals, pointers, structs, and much more.
Рекомендации по теме
Комментарии
Автор

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

hubercats
Автор

much things covered in 12 minutes awesome

studynewthings
Автор

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

Blackilykat
Автор

What is that %lf ?Please clear my doubt

sudalaitech
Автор

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 <stdio.h>

int main()
{
int a, b, c;
printf("Enter Two Values\n");
scanf("%d %d", &a, &b);
c=a+b;
printf("The Addition of Two Values %d And %d is %d");
return 0;
}
Help sir

Tatsumaki
Автор

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

anonimous
Автор

how would i take in user input that includes new lines (i.e. multi-line input)

brendongong
Автор

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! \n", name);

// ints
int age;
printf("Enter your age: ");
scanf("%d", &age);
printf("You are %d \n", age);

// chars
char grade;
printf("Enter your grade: ");
scanf("%c", &grade);
printf("You got an %c on the test \n", grade);

// doubles
double gpa;
printf("Enter your gpa: ");
scanf("%lf", &gpa);
printf("Your gpa is %f \n", gpa);

Anonymous-ybnl
Автор

one curious question... Are you really always coding and sitting like that? XD

unstablethermalpaste