eHow launches Android app: Get the best of eHow on the go.

How to Use the Memset Function in C++

Video Preview

Summary: 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.

Views:
755
Presenter
By Dave Andrews
eHow Presenter

Dave Andrews is a software developer with a business and Web site selling programs and other computer services in Franklin, Tenn. Having worked in the IT industry for more than 8...read more

Post a Comment

Post a Comment

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."

eHow Article: How to Use the Memset Function in C++

Related Ads

  • Have you done this? Click here to let us know.
Computers
Alexia Petrakos,

Meet Alexia Petrakos eHow's Computers Expert.

Get Free Computers Newsletters

Copyright © 1999-2009 eHow, Inc. Use of this web site constitutes acceptance of the eHow Terms of Use and Privacy Policy.   en-US Portions of this page are modifications based on work created and shared by Google and used according to terms described in the Creative Commons 3.0 Attribution License.

eHow Computers
eHow_eHow Technology and Electronics