weird behaviour with escape character
-
My application (under VC++ .net) should communicate with external hardware, with a protocol that requires the carriage return sent as a control character. However, when I add the "\r" to the string, e.g.
string s1="\r00220101\r";
my program seem to go nuts. I use a simple console program for test purposes,and when I try to print the string with "cout", the string doesn´t print at all and the order of the other "cout´s" seem totally random. There are no similar problems with "\n" or "\t". Does anybody have a suggestion regards doneirik -
My application (under VC++ .net) should communicate with external hardware, with a protocol that requires the carriage return sent as a control character. However, when I add the "\r" to the string, e.g.
string s1="\r00220101\r";
my program seem to go nuts. I use a simple console program for test purposes,and when I try to print the string with "cout", the string doesn´t print at all and the order of the other "cout´s" seem totally random. There are no similar problems with "\n" or "\t". Does anybody have a suggestion regards doneirik -
My application (under VC++ .net) should communicate with external hardware, with a protocol that requires the carriage return sent as a control character. However, when I add the "\r" to the string, e.g.
string s1="\r00220101\r";
my program seem to go nuts. I use a simple console program for test purposes,and when I try to print the string with "cout", the string doesn´t print at all and the order of the other "cout´s" seem totally random. There are no similar problems with "\n" or "\t". Does anybody have a suggestion regards doneirik -
Please share so that others may benefit.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
-
Please share so that others may benefit.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
Actually I don´t know exactly what was the cause... 1. I tried to send the characters using a string or character array. Forgot that en extra "\0" is added. This might have caused some problems. 2.The number of bytes to write parameter in the writefile function: I passed it as an int, then as a short. Had problems with int not with short. Still I don´t understand why or if this really caused the problems, and why it was only with the "\r".. doneirik