typedef struct tagDEFINITION_OF_RECORD_step1 { int isEnd; const char *cSearchItem; const char *cDisplayItem; const char *cWitchSettingItem; const char *cSettingItem; } UVS_STATICDB_RECORD_step1; typedef struct tagDEFINITION_OF_SETTING_TABLE_step1 { UVS_STATICDB_RECORD_step1 record[UVS_STATICDB_SETTING_RECORD_NUM_MAX]; } UVS_STATICDB_SETTING_TABLE_step1; typedef struct tagDEFINITION_OF_DB_step1 { const char *language; UVS_STATICDB_SETTING_TABLE_step1 tblSetting; } UVS_STATICDB_step1; extern UVS_STATICDB_step1 g_static_database_step1[]; 怎么给g_static_database_step1循环赋值
时间: 2023-08-02 08:09:41 浏览: 155
您可以使用以下代码循环赋值g_static_database_step1:
```c
#define NUM_LANGUAGES 3
#define NUM_SETTINGS 2
const char *languages[NUM_LANGUAGES] = {"English", "Spanish", "French"};
const char *searchItems[NUM_SETTINGS] = {"SearchItem1", "SearchItem2"};
const char *displayItems[NUM_SETTINGS] = {"DisplayItem1", "DisplayItem2"};
const char *witchSettingItems[NUM_SETTINGS] = {"WitchSettingItem1", "WitchSettingItem2"};
const char *settingItems[NUM_SETTINGS] = {"SettingItem1", "SettingItem2"};
const int isEnd = 0;
UVS_STATICDB_RECORD_step1 records[NUM_SETTINGS] = {
{isEnd, searchItems[0], displayItems[0], witchSettingItems[0], settingItems[0]},
{isEnd, searchItems[1], displayItems[1], witchSettingItems[1], settingItems[1]}
};
UVS_STATICDB_SETTING_TABLE_step1 settingTables[NUM_LANGUAGES] = {
{records},
{records},
{records}
};
UVS_STATICDB_step1 g_static_database_step1[NUM_LANGUAGES] = {
{languages[0], settingTables[0]},
{languages[1], settingTables[1]},
{languages[2], settingTables[2]}
};
```
这里我们使用了简单的数组和循环来赋值g_static_database_step1。首先,我们定义了一些常量和数组,然后使用循环和这些数组来填充每个结构体的值,最后将结构体放入到g_static_database_step1数组中。
阅读全文