如何定义cstring结构的arrary? [英] How do I define the arrary of struct of cstring?
问题描述
typedef struct SerialCfgPacket // 16 bytes설정> Serial Option에사용
{
char stx;
char cmd; //'U','u'
char mac [6];
char portno;
char itf;
char baudrate;
char databit;
char stopbit;
char parity;
char flow;
char etx;
} RP_S;
SerialCfgPacket rpdata_U [100];
int i;
CString strTmp;
if(strTmp == _T(RS232))rpdata_U [i] .itf = 0;
有编译错误:
'[':'SerialCfgPacket'没有定义这个运算符或者不能定义和允许任何类型的预定义运算符......等等
我不知道为什么以及如何解决这个问题。
我尝试了什么:
因为我是这个CString结构声明的新手
我浪费了3个小时的这个问题。
提前谢谢。
你不需要typedef
中的C ++
,只需使用
struct SerialCfgPacket
{
// ..
};
Quote:int i;
CString strTmp;
if(strTmp == _T(RS232) ))rpdata_U [i] .itf = 0;
在最后一个语句中,strTmp
和我
未初始化。
看起来你粘贴了稀疏的代码片段,甚至与你得到的错误信息无关。
typedef struct SerialCfgPacket // 16 bytes 설정>Serial Option에 사용 { char stx; char cmd;//'U','u' char mac[6]; char portno; char itf; char baudrate; char databit; char stopbit; char parity; char flow; char etx; } RP_S; SerialCfgPacket rpdata_U[100]; int i; CString strTmp; if (strTmp == _T("RS232")) rpdata_U[i].itf = 0;
has compile error:
'[': 'SerialCfgPacket' doesn't define this operator or cannot define and permit any type of pre-define operator...etc
I don't know why and how to fix it.
What I have tried:
Because I am novice of this CString structure declarations
I wasted 3 hours of this problem.
Thank you in advance.
You don't need thetypedef
inC++
, simply use
struct SerialCfgPacket { //.. };
Quote:int i;
CString strTmp;
if (strTmp == _T("RS232")) rpdata_U[i].itf = 0;
in the last statement, bothstrTmp
andi
are uninitialised.
It looks you pasted sparse pieces of code, not even relevant to the error message you got.
这篇关于如何定义cstring结构的arrary?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!