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. Reading char* buffer

Reading char* buffer

Scheduled Pinned Locked Moved C / C++ / MFC
helptutorial
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.
  • A Offline
    A Offline
    AbhiHcl
    wrote on last edited by
    #1

    Hi, I have some data in char *szBuffer. I need to read the data fom the buffer nad put them into respected variable. Suppose szBuffer returns "15,30\r\n CMD OK \r\n" , then I need to keep 15 in one variable,30 in other and CMD OK in other variable. Can anyone help me how to do this. Any sample code will be good help for me. Thanks..

    D A 2 Replies Last reply
    0
    • A AbhiHcl

      Hi, I have some data in char *szBuffer. I need to read the data fom the buffer nad put them into respected variable. Suppose szBuffer returns "15,30\r\n CMD OK \r\n" , then I need to keep 15 in one variable,30 in other and CMD OK in other variable. Can anyone help me how to do this. Any sample code will be good help for me. Thanks..

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

      Read up on tokenizing. See strtok() and strchr() for starters.

      "One man's wage rise is another man's price increase." - Harold Wilson

      "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

      "Man who follows car will be exhausted." - Confucius

      1 Reply Last reply
      0
      • A AbhiHcl

        Hi, I have some data in char *szBuffer. I need to read the data fom the buffer nad put them into respected variable. Suppose szBuffer returns "15,30\r\n CMD OK \r\n" , then I need to keep 15 in one variable,30 in other and CMD OK in other variable. Can anyone help me how to do this. Any sample code will be good help for me. Thanks..

        A Offline
        A Offline
        Aescleal
        wrote on last edited by
        #3

        The standard library is your friend if you're using C++. Have a look at: - istringstream - getline and see what you can cobble together. Cheers, Ash

        A 1 Reply Last reply
        0
        • A Aescleal

          The standard library is your friend if you're using C++. Have a look at: - istringstream - getline and see what you can cobble together. Cheers, Ash

          A Offline
          A Offline
          AbhiHcl
          wrote on last edited by
          #4

          Can u please provide some sample code, I m very new in c++. Thanks

          M 1 Reply Last reply
          0
          • A AbhiHcl

            Can u please provide some sample code, I m very new in c++. Thanks

            M Offline
            M Offline
            Member 4194593
            wrote on last edited by
            #5

            We don't do homework around here. You have been given enough hints of what to use and read up on. Try to get something wotking. If you then have problems, post your code and explain what does not work. Someone will try to help you out. Dave.

            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