Memset function in c language?

Yes, it can apply to any memory buffer, but you must input the correct memory buffer size memset treats any memory buffer as a series of bytes, so whether it's char int float double etc, doesn't really matter. Keep in mind though that it will not set multi-byte types to a specific non-zero value ... for example.

Yes, it can apply to any memory buffer, but you must input the correct memory buffer size ... memset treats any memory buffer as a series of bytes, so whether it's char, int, float, double, etc, doesn't really matter. Keep in mind though that it will not set multi-byte types to a specific non-zero value ... for example: int a100; memset(a, 1, sizeof(a)); will not set each member of a to the value 1 ... rather it will set every byte in the memory buffer taken up by a to 1, which means every four-byte int will be set to the value 0x01010101, which is not the same as 0x00000001.

For static-sized and variable-length arrays, you can just foo ...; memset (foo, 0, sizeof (foo)); // sizeof() gives size of entity in bytes Rule of thumb: Never hardcode data sizes. (This does not work if you pass arrays as function arguments: Behaviour of Sizeof in C ).

It can be applied to any array. The 100 at the end is the size in bytes, so a integer would be 4 bytes each, so it would be - int a100; memset(a, 0, sizeof(a)); //sizeof(a) equals 400 bytes in this instance Get it? :).

PS: It's not just arrays, its arbitrary memory blocks, you're setting memory from location to value 0 for a length of 400 bytes in my example - it doesn't care what the memory was formatted as. – w00te Jul 25 '11 at 12:56 arbitray memory blocks? – ratzip Jul 25 '11 at 12:58 1 -1: Never hardcode type sizes.

– phresnel Jul 25 '11 at 13:00 you really need to mention sizeof – David Heffernan Jul 25 '11 at 13:01.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions


Thank You!
send