LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Default value for a struct element

Solved!
Go to solution

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

0 Kudos
Message 1 of 3
(5,556 Views)
Solution
Accepted by topic author MathieuG

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

0 Kudos
Message 2 of 3
(5,554 Views)
Ok, thank you for the information!
0 Kudos
Message 3 of 3
(5,546 Views)