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. Replace CString Format()

Replace CString Format()

Scheduled Pinned Locked Moved C / C++ / MFC
c++question
2 Posts 2 Posters 6 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.
  • L Offline
    L Offline
    Lost User
    wrote on last edited by
    #1

    I would like to go over some old code and replace the use of CString (MFC / ATL) with a multiplatform, C++ 20 equivalent. Can I use std::format and if so, then how?

    Mircea NeacsuM 1 Reply Last reply
    0
    • L Lost User

      I would like to go over some old code and replace the use of CString (MFC / ATL) with a multiplatform, C++ 20 equivalent. Can I use std::format and if so, then how?

      Mircea NeacsuM Offline
      Mircea NeacsuM Offline
      Mircea Neacsu
      wrote on last edited by
      #2

      std::format is not directly compatible with sprintf formatting codes. From what I've seen there are different ways to go about this: - do sprintf to a temporary buffer and assign buffer to a std::string - switch to string streams (std::stringstream) and their "<<" operator - switch to std::format and their "{}" style formatting. None is automatic and about equally unpleasant.

      Mircea

      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