It looks like the simplest solution for you would be:
Code:
struct application {
int a_onehit = 1;
};
If you prefer, write the default constructor:
Code:
struct application {
application() : a_onehit(1) {}
int a_onehit;
};
If you really, really want to use a separate non-member function, then make use of a reference parameter:
Code:
struct application {
int a_onehit;
};
void fill_struct_application(application& x) {
x.a_onehit = 1;
}
but I don't recommend this as it is essentially unnecessary two-stage object construction. Do it for other use cases, i.e., setting the member variable to a replacement value.
Generally, you should not use malloc in C++ unless you're writing an allocator or need to do some special case stuff.