C array of strings🧵

preview_player
Показать описание
C array of strings tutorial example explained

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

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

int main()
{
char cars[][10] = {"Mustang", "Corvette", "Camaro"};

//cars[0] = "Tesla";
strcpy(cars[0], "Tesla");

for(int i = 0; i < sizeof(cars)/sizeof(cars[0]); i++)
{
printf("%s\n", cars[i]);
}

return 0;
}

BroCodez
Автор

Thanks, simple, straight to the point, analytical.

alexiosalexiou
Автор

One VERY important point when using strcpy() that really should have been mentionned:
The destination string should be large enough to accept the source string. Otherwise, it will overflow on other memory adresses and potentially corrupt your program

benoitgauthier
Автор

yours was the simplest to understand thank you.

mohammedazzan
Автор

ı really couldnt get this topic but now everything is clear. thanks you are the best🥺

kevser
Автор

damn you made our 30-60 min lecture into 3 mins

minari_
Автор

Thank you for this video! It can also be *cars[ ] in order to not have wastage of memory

marbles
Автор

Could u teach deeply? Like writing longer and more difficult codes

torexanovich
Автор

ı wish ı can like this video multiple times

kevser
Автор

Can you replace for example "tesla" with a variable that ="tesla" ?

sebastienroux
Автор

and how the hell do i take input from user?

kyte
Автор

I dont understand the math for the for loop... sizeof(cars) would be 2, since 0 counts as an index. sizeof(cars[0]) is Tesla, which is 5 characters... so wouldn't you be comparing 0, 1, and 2 against 2/5 which is 0.4? so shouldn't the loop break after the first element? so confused...

TheLivingCrittles
Автор

dark theme sucks. view is not clear. use light color

MostaphaQamar