Keeping strcpy and memcpy straight when copying memory.

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

Students often use strcpy when they should be using memcpy, and vice versa. This video explains the difference, and hopefully helps you keep them straight in your projects.



***

Welcome! I post videos that help you learn to program and become a more confident software developer. I cover beginner-to-advanced systems topics ranging from network programming, threads, processes, operating systems, embedded systems and others. My goal is to help you get under-the-hood and better understand how computers work and how you can use them to become stronger students and more capable professional developers.

About me: I'm a computer scientist, electrical engineer, researcher, and teacher. I specialize in embedded systems, mobile computing, sensor networks, and the Internet of Things. I teach systems and networking courses at Clemson University, where I also lead the PERSIST research lab.

More about me and what I do:



***

Welcome! I post videos that help you learn to program and become a more confident software developer. I cover beginner-to-advanced systems topics ranging from network programming, threads, processes, operating systems, embedded systems and others. My goal is to help you get under-the-hood and better understand how computers work and how you can use them to become stronger students and more capable professional developers.

About me: I'm a computer scientist, electrical engineer, researcher, and teacher. I specialize in embedded systems, mobile computing, sensor networks, and the Internet of Things. I teach systems and networking courses at Clemson University, where I also lead the PERSIST research lab.

More about me and what I do:

To Support the Channel:
+ like, subscribe, spread the word

Want me to review your code?

You can also find more info about code reviews here.
Рекомендации по теме
Комментарии
Автор

strncpy isn't just like strncpy except for copying only up to n bytes. It actually always writes exactly n bytes:

"If the length of src is less than n, strncpy() writes additional null bytes to dest to ensure that a total of n bytes are written."

paulk
Автор

This is the first channel where I found the actual usage of memcpy()

DhimantThanki
Автор

I am watching all your videos from begining till end because i really lile the content...

I have a question though..

how can system() be exploited if im just using const char in it ?!

prashanthkumar
Автор

strncpy() is a misleading name, so often associated with strcpy. and strcat().
If strlen( src ) >= len, this function is equivalent to memcpy() and does not guarantee a null terminated string in the destination.
Just something to be aware of...

rustycherkas
Автор

If the length of the string is known, is memcpy() faster than strcpy()?
Or do the perfom equal in most implementations?

No one implements strcpy() with calls to strlen() + memcpy() I hope...

maxaafbackname
Автор

But then we could use memcpy instead of strncpy to copy upto a certain no of bytes?

aritrasurroy
Автор

Is 0 the null character ? I thought it was \0 ?

KFlorent
Автор

i USED STRCPY GOT HACKED THEY TOOK OVER MY APP

imveryhungry
visit shbcf.ru