struct A
{
    int num;
    char name[5];
    //这里有上1000个变量
}a;
我要将变量名num,name,...... 加入到combo box 中的LIST去,怎么做??
项目提供了几个头文件,每个头文件都有多个结构体,每个结构体都可能有几种数据类型,所以变量名肯定超1000了,有好的方法吗??
请写详细些!如果有好方法解决,再送100分

解决方案 »

  1.   

    TO:an_bachelor(洗澡就是浪費生命) 
    你能写出详细的代码吗?
    我的开发环境:.net\vc++\mfc\mfc application\dialog 在那里没有找到答案,所以到这样看看有没有什么好方法
      

  2.   

    CString str = "int num;....";
    CString strCode("");for (INT iStart = 0, iFoundPos = 0, iIndex = 0; (iFoundPos != -1) && (iStart < str.GetLength());)
    {
    iFoundPos = str.Find(_T(';'), iStart);
    if (-1 != iFoundPos)
    {
    strCode += "m_comb.AddString(";
    strCode += str.Mid(iStart, iFoundPos - iStart);
    strCode += ");" iStart = iFoundPos + 1;
    }
    }
      

  3.   

    str.Mid(iStart, iFoundPos - iStart);得到的就是一行語句
    從中提取變量名 可以用一個正則表達式或者簡單地從字符串末向前檢測
    過濾空格、匹配的括號、方括號 這裡就是變量名的中止位置 然後繼續向前
    踫到第一個不是字母/數字的字符就是起始位置