strcpy() and strncpy() functions | C Programming Tutorial

preview_player
Показать описание
Рекомендации по теме
Комментарии
Автор

Thank you so much. You are a life saver, man.

juliaarmstrong
Автор

thank you so much. please I have a question how we can use all that using the pointers ?

abdelmalekelmansouri
Автор

Hii its me again :P
I have a situation where i have to copy the end of the string instead of the first few characters of the string, how can I do it?
Eg. you input into the terminal going './bin/library bin/books.txt' but i just need the 'bin/books.txt' bit to be used inside a fopen() function, and the .txt file could be another file name with longer characters, so how can I make it possible? Thank you!

yamithere_
Автор

Hello. I've been using DevC++ and a terminal (in CodeChum), and then when I tried:

char src[10] = "123456789";
char dest2[5];
strcpy (dest2, src);

printf ("%s", dest2);
return 0;

They are still printing the exact 123456789. How could have this happened? Help please.

marbles
Автор

What compiler do you use like in general the app you use

utwahmwingira
Автор

I noticed that the first source array is src[10] and you keep mentioning that it has 10 characters. Later you say that the arrays start counting at 0. If the string src[10] started counting at 0, it would mean that it would have a length of 11 characters. There would be 9 characters of the numbers 1 to 9, the '\0', and at the 10 character of the array (which would be the 11th total character) there would just be an empty space. I feel like this is not right but I am confused, could you please explain?

jonballanca
Автор

Why the code below doesn't produce any error? I use 9 as the size of the destination string even though I have to specify 10 or more (because of the \0 character)

char src[] = "12346789";
char dest1[9];
printf("%s", strcpy(dest1, src));

liri
Автор

Mr.Portfolio Courses. I have 12345678, how a can copy only 3456 ????

angelldark
Автор

We have to put 10 characters in src[10 ] because we count from 0 so we can put our 10 characters and \0 will put at 10 (11)

bozomozo
Автор

Good video, but it doesn't contain enough information to rebuild strncpy(); yourself.

JV-
welcome to shbcf.ru