Designing structure with number of char array field in it
<p>I have following Structure in my Program. </p>

<pre><code>#define WIFI_DEVICE_NAME 100
#define WIFI_SERIAL_NO 13       
#define WIFI_PROD_NAME 7


typedef struct WiFiDeviceInfo
{
    char name[WIFI_DEVICE_NAME];                
    char fullname [WIFI_DEVICE_NAME];               
    char productname[WIFI_PROD_NAME];               
    char serialnumber[WIFI_SERIAL_NO];              
};
</code></pre>

<p>This Struct is used in the various places. Some time some of the fields may remain empty. So while copying using <code>strcpy_s()</code>, it fails. So I tried with <code>strlen()</code> before doing any copy operation.</p>

<p>I modified the struct and came up with the following design.</p>

<pre><code>typedef struct WiFiDeviceInfo
{
    char name[WIFI_DEVICE_NAME];    
    unsigned short nLenName;            
    char fullname [WIFI_DEVICE_NAME];   
    unsigned short nLenFullName;            
    char productname[WIFI_PROD_NAME];
    unsigned short nproductname;                            
    char serialnumber[WIFI_SERIAL_NO];              
};
</code></pre>

<p>I can't use STL here since its legacy code, which doesn't use STL.
Is there any better way to design the structure.</p>
