C Programming Tutorial 18, Arrays pt.3

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

Рекомендации по теме
Комментарии
Автор

One of the best videos on c programming on Youtube...It's an absolute must for student having difficulty with c programming.

ketz
Автор

Gosh, you help me out in doing my assignment very well, thanks dude ! I like your tutorial..

windday
Автор

Love your tutorials! Question regarding this code:

char name[20];
printf("please enter your name: ");
scanf("%s", &name);


My complier gives me the following warning:

warning: format ‘%s’ expects type ‘char *’, but argument 2 has type ‘char (*)[20]

So I searched around, and found one suggestion online, which worked for me, lose the '&' in the scanf line.




TaliWalt
Автор

You should get a lot more views! You're amazing

gs
Автор

Please make a tutorial how to compare strings in (if, else ) function

arenagods
Автор

(this is a continuation of my previous post)

Here is the explanation given for getting rid of the '&':

"%s" means that scanf is expecting a pointer to the first element of a char array. me is an object array and could evaluated as pointer. So that's why you can use me directly without adding &. Adding & to me will be evaluated to ‘char (*)[20]’ and your scanf is waiting char *

So, how is it possible that one line of code works for you, but not for me? Is it a compiler thing?

TaliWalt
Автор

You forgot to mention that there's a \0 at the end of every string

massimogiardina
Автор

That's pretty much it for this tutorial..so, see you guys!

muhammadsada
Автор

so that's pretty much it for this tutorial, so see you guys!

OneTimWhatley
Автор

I fucked up in the video, I shouldn't have put the & there. The thing is though, arrays in C are kinda weird. &myArray is actually the same thing as just plain old myArray. The 'error' that you're getting is actually just a warning, so you can ignore it.

iTzAdamX
Автор

Why cant i do this


char newWord[10];
printf("Enter a new sentence: ");
scanf("%s", &newWord);
printf("%s", newWord);


m.mohammad
welcome to shbcf.ru