Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. weird behaviour with escape character

weird behaviour with escape character

Scheduled Pinned Locked Moved C / C++ / MFC
csharpc++hardwarelounge
5 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    doneirik
    wrote on last edited by
    #1

    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

    A D 2 Replies Last reply
    0
    • D 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

      A Offline
      A Offline
      AslFunky
      wrote on last edited by
      #2

      Hi, I too dont have any correct idea, but you can try doing one thing. try clearing the output stream, perhaps using something equivalent to fflush(stdin) or a flushall before couting anything. Hope that helps. Bye. AslFunky

      1 Reply Last reply
      0
      • D 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

        D Offline
        D Offline
        doneirik
        wrote on last edited by
        #3

        solved it. (more or less)

        D 1 Reply Last reply
        0
        • D doneirik

          solved it. (more or less)

          D Offline
          D Offline
          David Crow
          wrote on last edited by
          #4

          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

          D 1 Reply Last reply
          0
          • D 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

            D Offline
            D Offline
            doneirik
            wrote on last edited by
            #5

            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

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups