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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. get number from string

get number from string

Scheduled Pinned Locked Moved C / C++ / MFC
questionjson
3 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.
  • W Offline
    W Offline
    wow9999
    wrote on last edited by
    #1

    Dear All CString s("-1, 1, 10"); How can i get all of these three numbers out this string? I used atof(s), but i can only get first number, -1. How can i get rest of number, 1 and 10? Thanks

    M N 2 Replies Last reply
    0
    • W wow9999

      Dear All CString s("-1, 1, 10"); How can i get all of these three numbers out this string? I used atof(s), but i can only get first number, -1. How can i get rest of number, 1 and 10? Thanks

      M Offline
      M Offline
      mmwhw
      wrote on last edited by
      #2

      you can define a function CString getfirstparam(CString& strParam) { CString str,str1; int i; i = strParam.find(','); str = strParam.left(i); str1= strParam.right(strParam.Getlength()-i-1); strParam =- str1; return str; }

      1 Reply Last reply
      0
      • W wow9999

        Dear All CString s("-1, 1, 10"); How can i get all of these three numbers out this string? I used atof(s), but i can only get first number, -1. How can i get rest of number, 1 and 10? Thanks

        N Offline
        N Offline
        Nish Nishant
        wrote on last edited by
        #3

        CString s("-5 4 10");
        int i, j, k;
        sscanf(s,"%d %d %d",&i,&j,&k);
        //printf("i=%d j=%d k=%d\r\n",i,j,k);

        Replace printf with your stuff... Nish


        Author of the romantic comedy Summer Love and Some more Cricket [New Win] Review by Shog9 Click here for review[NW]

        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