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. Carriage return- How to identify?

Carriage return- How to identify?

Scheduled Pinned Locked Moved C / C++ / MFC
questiontutorial
5 Posts 4 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
    Deepak Samuel
    wrote on last edited by
    #1

    Hi, how can I identify a carriage return (\n)using fscanf ? Thanks, Deepak Samuel.

    R 1 Reply Last reply
    0
    • D Deepak Samuel

      Hi, how can I identify a carriage return (\n)using fscanf ? Thanks, Deepak Samuel.

      R Offline
      R Offline
      rw104
      wrote on last edited by
      #2

      It has an ascii value of decimal 13, eg. if(nChar==13)AfxMessageBox("Carriage Return");

      D 1 Reply Last reply
      0
      • R rw104

        It has an ascii value of decimal 13, eg. if(nChar==13)AfxMessageBox("Carriage Return");

        D Offline
        D Offline
        Deepak Samuel
        wrote on last edited by
        #3

        I am scanning the file for interger values what happens if my file itself contains a integer value of 13 ? How can I differentiate between my data and a carriage return?` Thanks, Deepak Samuel

        J D 2 Replies Last reply
        0
        • D Deepak Samuel

          I am scanning the file for interger values what happens if my file itself contains a integer value of 13 ? How can I differentiate between my data and a carriage return?` Thanks, Deepak Samuel

          J Offline
          J Offline
          jerry1211a
          wrote on last edited by
          #4

          Maybe you can tell by looking for CR, LF...at the end of each line.

          1 Reply Last reply
          0
          • D Deepak Samuel

            I am scanning the file for interger values what happens if my file itself contains a integer value of 13 ? How can I differentiate between my data and a carriage return?` Thanks, Deepak Samuel

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

            Character 13 and number 13 are totally different things. When using fscanf(), you must tell it what type of data is being read. In other words:

            char c;
            fscanf(pFile, "%c", &c);

            This will not read the number 13 from the file. Likewise:

            int n;
            fscanf(pFile, "%d", &n);

            This will not read the character 13 from the file. Make sense?


            "When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen

            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