Skip to content

Instantly share code, notes, and snippets.

@larsiusprime
Created May 26, 2017 20:15
Show Gist options
  • Save larsiusprime/f57a0c48a4cf3ee43b5c263a1b58d044 to your computer and use it in GitHub Desktop.
Save larsiusprime/f57a0c48a4cf3ee43b5c263a1b58d044 to your computer and use it in GitHub Desktop.

So say I have a function like this:

int doSomeStuff(
   const SomeStruct *myStruct
)

And SomeStruct is defined like this:

typedef struct SomeStruct {
    char data[16];
    int num;
    bool whatever;
} SomeStruct;

...How do I properly declare an instance of SomeStruct and feed it into doSomeStuff() ?

@ibilon
Copy link

ibilon commented May 26, 2017

Something like

SomeStruct obj;
obj.data[0] = 'a';
obj.num = 42;
obj.whatever = true;
doSomeStuff(&obj);

should work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment