Memset a struct

Discussion in 'C Programming' started by BrainV, May 4, 2010.

  1. BrainV

    BrainV

    Joined:
    May 4, 2010
    Messages:
    2
    Likes Received:
    0
    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?
     
    BrainV, May 4, 2010
    #1
    1. Advertisements

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. RA Scheltema
    Replies:
    3
    Views:
    599
    RA Scheltema
    Jan 6, 2004
  2. Gunnar G

    struct in struct

    Gunnar G, May 31, 2004, in forum: C++
    Replies:
    14
    Views:
    1,037
  3. DanielEKFA
    Replies:
    8
    Views:
    842
    DanielEKFA
    May 16, 2005
  4. James Harris
    Replies:
    4
    Views:
    1,774
    James Harris
    Oct 9, 2003
  5. Chris Fogelklou
    Replies:
    36
    Views:
    1,828
    Chris Fogelklou
    Apr 20, 2004
  6. Fernan Bolando

    Pointer to struct or Struct parameters

    Fernan Bolando, Aug 7, 2004, in forum: C Programming
    Replies:
    6
    Views:
    551
    Fernan Bolando
    Aug 8, 2004
  7. Mark A. Odell

    Q: volatile struct elements or entire struct?

    Mark A. Odell, Sep 22, 2004, in forum: C Programming
    Replies:
    3
    Views:
    863
    Mark A. Odell
    Sep 23, 2004
  8. Mark

    memset() on a struct or union

    Mark, Feb 2, 2010, in forum: C Programming
    Replies:
    21
    Views:
    13,378
    Richard Bos
    Feb 3, 2010
Loading...