CString problem
-
Hi there, now I have a problem with my buffer. I have a buffer reading in data from the serial port data is passed into the buffer like this
m_serialbuffer += ch; //where m_etc is a CString and ch is a string read from the serial buffer
Now this works perfectly for the first string that is sent to the port and stores it. For subsequent strings though, no characters are added. Any ideas?? andy
-
Hi there, now I have a problem with my buffer. I have a buffer reading in data from the serial port data is passed into the buffer like this
m_serialbuffer += ch; //where m_etc is a CString and ch is a string read from the serial buffer
Now this works perfectly for the first string that is sent to the port and stores it. For subsequent strings though, no characters are added. Any ideas?? andy
Is there a chance for the NULL character '\0'? CStrings are NULL terminated. John
-
Is there a chance for the NULL character '\0'? CStrings are NULL terminated. John
-
If there is a zero (ASCII 0 not the number 0) in the input the CString will not add any more characters. John
-
If there is a zero (ASCII 0 not the number 0) in the input the CString will not add any more characters. John
-
hmm yes I think there is a zero on the end of the first string. How can I get around this?
Either strip the 0 with an if statement or use an array like CArray or vector. John
-
Either strip the 0 with an if statement or use an array like CArray or vector. John
-
hmm yes I think there is a zero on the end of the first string. How can I get around this?
Appending 0-terminated strings to a CString object is expected.
char *name = "David"; // there is an implied \0 at the end of this string CString str = "My name is "; str += name;
-
Hi there, now I have a problem with my buffer. I have a buffer reading in data from the serial port data is passed into the buffer like this
m_serialbuffer += ch; //where m_etc is a CString and ch is a string read from the serial buffer
Now this works perfectly for the first string that is sent to the port and stores it. For subsequent strings though, no characters are added. Any ideas?? andy
The comment in this code snippet appears to be outdated. Have you stepped into the code to verify that 'ch' has valid data at the time of appending? When you state that "ch is a string", does that mean it is a string object, or are you using string in the generic sense (e.g., char ch[32])?