请教:关于CString 数组的问题。谢谢

zhangning2095 2008-11-21 09:01:48
代码大概如下吧先定义一个全局函数:CString str[];
然后函数代码大致如下:
void savedata( DAB_SERVICE_INFO *service ,int size )
{
for (int i=0;i<size;i++)
{
CString str_ServiceLabel;
str_ServiceLabel = service->ServiceLabel;
str_ServiceLabel.Format(L"%s\r\n",str_ServiceLabel );

InfoLabel[i] = str_ServiceLabel; /*error LNK2001: 无法解析的外部符号 "class ATL::CStringT<wchar_t,class //StrTraitMFC_DLL<wchar_t,class ATL::ChTraitsCRT<wchar_t> > > * InfoLabel" (?InfoLabel@@3PAV?//$CStringT@_WV?$StrTraitMFC_DLL@_WV?$ChTraitsCRT@_W@ATL@@@@@ATL@@A)
Si_Offset.exe : fatal error LNK1120: 1 个无法解析的外部命令*/

service++;
}

}
以上是错误,那位高手告诉我为什么会这样啊。我想把service->ServiceLabel的参数保存在str[]中,请问该怎么办,谢谢。
...全文
151 8 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
sandy_zc_1 2008-11-22
  • 打赏
  • 举报
回复
因为你没有定义InfoLabel,当然就成为无法解析的外部符号了。
zhangning2095 2008-11-21
  • 打赏
  • 举报
回复
多谢了。。刚才我写错了。。应该是全局函数CString InfoLabel[];我不知道为什么会出现上述错误。。ps:感谢大家的建议
量子 2008-11-21
  • 打赏
  • 举报
回复
sorry
系统故障
量子 2008-11-21
  • 打赏
  • 举报
回复
InfoLabel[]的类型是什么?
以下几处修改是我觉得编程习惯不好的,建议改掉。

void savedata( DAB_SERVICE_INFO *service ,int size )
{
for (int i=0;i <size;i++)
{
CString str_ServiceLabel; //放到for 循环外面
//添加str_ServiceLabel="";
str_ServiceLabel = service->ServiceLabel;
str_ServiceLabel.Format(L"%s\r\n",str_ServiceLabel ); //
//改成str_ServiceLabel+="\r\n";

InfoLabel[i] = str_ServiceLabel;
service++;
}

}
量子 2008-11-21
  • 打赏
  • 举报
回复
InfoLabel[]的类型是什么?
以下几处修改是我觉得编程习惯不好的,建议改掉。

void savedata( DAB_SERVICE_INFO *service ,int size )
{
for (int i=0;i <size;i++)
{
CString str_ServiceLabel; //放到for 循环外面
//添加str_ServiceLabel="";
str_ServiceLabel = service->ServiceLabel;
str_ServiceLabel.Format(L"%s\r\n",str_ServiceLabel ); //
//改成str_ServiceLabel+="\r\n";

InfoLabel[i] = str_ServiceLabel;
service++;
}

}
量子 2008-11-21
  • 打赏
  • 举报
回复
InfoLabel[]的类型是什么?
以下几处修改是我觉得编程习惯不好的,建议改掉。

void savedata( DAB_SERVICE_INFO *service ,int size )
{
for (int i=0;i <size;i++)
{
CString str_ServiceLabel; //放到for 循环外面
//添加str_ServiceLabel="";
str_ServiceLabel = service->ServiceLabel;
str_ServiceLabel.Format(L"%s\r\n",str_ServiceLabel ); //
//改成str_ServiceLabel+="\r\n";

InfoLabel[i] = str_ServiceLabel;
service++;
}

}
schlafenhamster 2008-11-21
  • 打赏
  • 举报
回复
不是CArrayCString是CStringArray
见习学术士 2008-11-21
  • 打赏
  • 举报
回复
CString数组可以用CArrayCString呀。。

16,548

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC相关问题讨论
社区管理员
  • 基础类社区
  • AIGC Browser
  • encoderlee
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

        VC/MFC社区版块或许是CSDN最“古老”的版块了,记忆之中,与CSDN的年龄几乎差不多。随着时间的推移,MFC技术渐渐的偏离了开发主流,若干年之后的今天,当我们面对着微软的这个经典之笔,内心充满着敬意,那些曾经的记忆,可以说代表着二十年前曾经的辉煌……
        向经典致敬,或许是老一代程序员内心里面难以释怀的感受。互联网大行其道的今天,我们期待着MFC技术能够恢复其曾经的辉煌,或许这个期待会永远成为一种“梦想”,或许一切皆有可能……
        我们希望这个版块可以很好的适配Web时代,期待更好的互联网技术能够使得MFC技术框架得以重现活力,……

试试用AI创作助手写篇文章吧