How to Use the Memset Function in C++

Save
Next Video:
How to Partition a Hard Drive Without Data Loss....5

Using the memset function in C++ will take an array of allocated memory and set a certain number of bytes to a given byte. Understand using memset function with information from an experienced software developer in this free video on computers.

Part of the Video Series: Computer Information
Promoted By Zergnet

Comments

Video Transcript

Hi, my name is Dave Andrews. Today I'm going to show you how to use the memset function is C Pos Pos. Let's go to our computer. I have here a little program, written in C Pos Pos that uses our memset function which is here. Now memset is short for memory set which will basically take an array of memory that you have allocated and it will set a certain number of bytes to a given byte that you give to it. So in my program here I include IO string which will give me the CL object that lets me print to the screen and memset is a part of string.h so I include that there. Now the very first thing that I do is I create a string and I basically assign to it the values of 1, 2, 3, 4, 5, 6, 7, 8, 9, 0 just so I can have some data in my string. The next thing that I'll do is I'll take my string right here and I run the memset function on it giving the array, string 1 as in input and the byte which is actually shown here as a character of an uppercase X. Now C Pos Pos is going to translate that X to a byte value which would be the SK value of X. And I tell it to set 3 bytes worth of data. So I memset my array, what I want to put inside of that array and the number of bytes that I want to set. And then I print out the string after the data has been set. Now what I should get is this exact string up here, but the first three characters of it should be an X instead. Let's compile our program and then I'm going to run the output of that program. And then as you can see I have three X's and then the rest of that string. My name is Dave Andrews and I've just showed you how to use the memset function in C Pos Pos.

Featured

Related Searches

M
Is DIY in your DNA? Become part of our maker community.
Submit Your Work!