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. Easier way to convert this.....

Easier way to convert this.....

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

    Hello, I was wondering if anyone had a good idea on how to convert the following... CString strN; strN.Format("%d", nNum); // where nNum is something like 1123456 I would like to see the output of strN equal "1,123,456" Is there a easy way to do this? Rob Whoever said nothing's impossible never tried slamming a revolving door!

    A G 2 Replies Last reply
    0
    • R RobJones

      Hello, I was wondering if anyone had a good idea on how to convert the following... CString strN; strN.Format("%d", nNum); // where nNum is something like 1123456 I would like to see the output of strN equal "1,123,456" Is there a easy way to do this? Rob Whoever said nothing's impossible never tried slamming a revolving door!

      A Offline
      A Offline
      Alvaro Mendez
      wrote on last edited by
      #2

      Someone mentioned the API GetNumberFormat a few days ago. It's the fancy way of doing it. I'm sure you can whip up a quick for loop that will do it just as well. Regards, Alvaro


      Hey! It compiles! Ship it.

      1 Reply Last reply
      0
      • R RobJones

        Hello, I was wondering if anyone had a good idea on how to convert the following... CString strN; strN.Format("%d", nNum); // where nNum is something like 1123456 I would like to see the output of strN equal "1,123,456" Is there a easy way to do this? Rob Whoever said nothing's impossible never tried slamming a revolving door!

        G Offline
        G Offline
        godbert
        wrote on last edited by
        #3

        Why don t u just put a comma after the third, the sixth... char? Just make a loop which every 3 char inserts a comma with CString::Insert for instance. Something like this: for(i,from begining to the end of the cstring) { if(i==3or6or9) urstring.insert(",") //not the good syntax but u get the idea across } Is it what u meant? hope it s of any help 2 u. syl sysy

        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