[Resolved]memset problems
Moderator: Board moderators
-
- Experienced poster
- Posts: 147
- Joined: Fri Jun 13, 2003 10:46 pm
[Resolved]memset problems
i sometimes get strange results when i try to use memset to initialize an array. if i have something like memset(arr,0,___) sometimes it doesnt initilize anything, and sometimes it initializes to strange values. what should the third parameter be? something like sizeof(int)*arraysize if my array is int?
Last edited by bugzpodder on Mon Jul 28, 2003 4:54 pm, edited 1 time in total.
as far as i know, works when the memory allocation is static.
should work for both static and dynamic allocation of memory.
Code: Select all
memset(arr,0,sizeof(arr))
Code: Select all
memset(arr,0,sizeof(datatype)*arraysize)
K M Hasan
http://www.cs.umanitoba.ca/~kmhasan/
http://www.cs.umanitoba.ca/~kmhasan/