H
hitbuyi
Guest
My problem is stringstream not repeat properly, VS2015, MFC C++, code is below
stringstream sstrTime_chx_msgID;
stringstream tempss;
string tempStr;
string str_Time_chx_msgID[3];
double timeStamp;
int loop = 0;
int i;
CString test_ytx[3] = {
"0.024745 1 456 Rx d 5 00 00 06 E0 00 Length = 183910 BitCount = 96 ID = 1110",
"0.024979 1 457 Rx d 8 08 0F F0 0A 4D 38 7E A0 Length = 225910 BitCount = 117 ID = 1111",
"0.024979 1 458 Rx d 8 18 0F F0 0A 4D 38 7E A0 Length = 225910 BitCount = 119 ID = 1121"
};
for(i = 0; i < 3; i ++)
{
tempss.str("");
sstrTime_chx_msgID.str("");
sstrTime_chx_msgID = test_ytx.Mid(0,23); // get first three data of a line in test_ytx[3]
for (loop = 0; loop < 3; loop++)
{
sstrTime_chx_msgID >> tempStr;
str_Time_chx_msgID[loop] = tempStr;
}
strTime = (str_Time_chx_msgID[0].c_str()); // convert string type to MFC CString
tempss << str_Time_chx_msgID[0];
tempss >> timeStamp; // get time stamp,PROBLEM here
}
Problem is as following:
i = 0; str_Time_chx_msgID = "0.024745 1 456", timeStamp = 0.024745; right
i = 1; str_Time_chx_msgID = "0.024979 1 457", timeStamp = 0.024745; WRONG, WHY timeStamp is not update? I have cleared
tempss via statement
tempss.str("");
at the first of for statement
why? any one can help me?
Continue reading...
stringstream sstrTime_chx_msgID;
stringstream tempss;
string tempStr;
string str_Time_chx_msgID[3];
double timeStamp;
int loop = 0;
int i;
CString test_ytx[3] = {
"0.024745 1 456 Rx d 5 00 00 06 E0 00 Length = 183910 BitCount = 96 ID = 1110",
"0.024979 1 457 Rx d 8 08 0F F0 0A 4D 38 7E A0 Length = 225910 BitCount = 117 ID = 1111",
"0.024979 1 458 Rx d 8 18 0F F0 0A 4D 38 7E A0 Length = 225910 BitCount = 119 ID = 1121"
};
for(i = 0; i < 3; i ++)
{
tempss.str("");
sstrTime_chx_msgID.str("");
sstrTime_chx_msgID = test_ytx.Mid(0,23); // get first three data of a line in test_ytx[3]
for (loop = 0; loop < 3; loop++)
{
sstrTime_chx_msgID >> tempStr;
str_Time_chx_msgID[loop] = tempStr;
}
strTime = (str_Time_chx_msgID[0].c_str()); // convert string type to MFC CString
tempss << str_Time_chx_msgID[0];
tempss >> timeStamp; // get time stamp,PROBLEM here
}
Problem is as following:
i = 0; str_Time_chx_msgID = "0.024745 1 456", timeStamp = 0.024745; right
i = 1; str_Time_chx_msgID = "0.024979 1 457", timeStamp = 0.024745; WRONG, WHY timeStamp is not update? I have cleared
tempss via statement
tempss.str("");
at the first of for statement
why? any one can help me?
Continue reading...