of course can't do this
typedef struct {
char name[50] = "not_set_yet";
int ssn = 111223333;
} employee;
is: employee emp1 = {"not_set_yet", 111223333}; the only way?
what is the most elegant way to have default values for all instances of that type of struct?
|
Ambitious contributor
|
|
| 15Jan2008,15:23 | #2 |
|
You write it as C++, and supply a default constructor function.
Or if you're stuck with C, then your approach is one of several roughly equal approaches. None of which would be as elegant as using C++. |
|
Contributor
|
|
| 15Jan2008,15:27 | #3 |
|
if you want to initialize everything with a zero...
u can go for Code:
employee emp1 = {0};
|
|
Newbie Member
|
|
| 15Jan2008,20:11 | #4 |
|
Quote:
Originally Posted by technosavvy |
