12-01-2008 10:26 AM
Hello,
I would like to know if it is possible to assign a default value for a struct element?
Something like:
struct Device {
int ID;
double position;
char IPAddress[10]="127.0.0.1";
int TimeOut=25000;
};
Thank you for your help!
Best regards,
Mathieu
Solved! Go to Solution.
12-01-2008 10:35 AM
Hi,
in C a struct is a data type, and you cannot assign a default value to it.
You can assign a default value to a variable of type struct, with the following syntax
struct Device myDevice = { 0, 0, "127.0.0.1", 25000};
Hope this helps,
Aldo
12-01-2008 10:46 AM