Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > Memset a struct

Reply
Thread Tools

Memset a struct

 
 
BrainV BrainV is offline
Junior Member
Join Date: May 2010
Posts: 2
 
      05-04-2010
Hello

I've got a struct in a class in the private field.


Private:
tyepdef struct mystruct
{
char date[10];
char time[10];
char name[20];
} MYSTRUCT;

MYSTRUCT MyStruct;


Then I access it through some setter functions, for each element.

I then have have a function that simply prints out each element of the struct to a file using fprintf. My issue is after I've printed the data, I want to be able to clear it, so I tried to use the memset function
memset(MyStruct, '\0', sizeof(MyStruct));

However when I compile I get the following error error C2664 'memset' : cannot convert parameter 1 from "class1::MYSTRUCT" to 'void*'



Any idea how to fix this or to clear the struct?
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Can *common* struct-members of 2 different struct-types, that are thesame for the first common members, be accessed via pointer cast to either struct-type? John Reye C Programming 28 05-08-2012 12:24 AM
memset() on a struct or union Mark C Programming 21 02-03-2010 03:17 PM
memset vs fill and iterators vs pointers Joe C C++ 5 08-24-2004 11:51 AM
struct my_struct *p = (struct my_struct *)malloc(sizeof(struct my_struct)); Chris Fogelklou C Programming 36 04-20-2004 08:27 AM
2 questions: speed of memset() and pointer to multi-arrays k-man C++ 4 12-18-2003 08:52 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57