How to use memset for double dimentional array?

Since the arrays are laid in continuos address spaces, you don't have to do anything special for 2d arrays. You can simply use memset(alarm_1_active_buffer, 0, MAX_NUM_ALARMS * MAX_ALARM_STRING_SIZE * sizeof(type of alarm_1_active_buffer)).

Since the arrays are laid in continuos address spaces, you don't have to do anything special for 2d arrays. You can simply use memset(alarm_1_active_buffer, 0, MAX_NUM_ALARMS * MAX_ALARM_STRING_SIZE * sizeof(type of alarm_1_active_buffer));.

It will clear the whole array...i want to clear only the I th index.. – mujahid Feb 23 '11 at 9:52 Umm..alarm_1_active_bufferindex = 0 – Asha Feb 23 '11 at 10:01 You can just clear the entire array at once -- you don't need to iterate through the outer array and clear each index. – Conrad Meyer Feb 23 '11 at 11:05 1 Tip: When using the sizeof operator, refer to the variable itself, dereferencing if needed, instead of naming the type explicitly (e.g. , sizeof **alarm_1_active_buffer instead of sizeof (char)). This prevents bugs that crop up when the variable's type changes and one of the sizeof instances that references the old type isn't changed along with it.

– Blrfl Feb 23 '11 at 12:54.

Making sure to #include first: memset(alarm_1_active_buffer, 0, sizeof(alarm_1_active_buffer)); This method works regardless of the type of elements in the array.

I 'm confused: from the man page: #include void * memset(void *b, int c, size_t len); DESCRIPTION The memset() function writes len bytes of value c (converted to an unsigned char) to the byte string b. How can you memset a string then? Make sure the "string" value is of type int.

The linux man pages describe it as: void *memset(void *s, int c, size_t n); The memset() function fills the first n bytes of the memory area pointed to by s with the constant byte c. Maybe that is less confusing. But really, you shouldn't be posting "answers" which ask more questions.

– Conrad Meyer Feb 23 '11 at 11:04 Well I need to have +50 in reputation to post a comment, which I have not. Next time I'll just shut my mouth. – Pierre Guilbert Feb 23 '11 at 14:36.

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