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. sprintf

sprintf

Scheduled Pinned Locked Moved C / C++ / MFC
helptutorialquestion
3 Posts 2 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.
  • S Offline
    S Offline
    styve
    wrote on last edited by
    #1

    Hi! I'm using sprintf to get an integer into a string. When I using strcpy I can use strcat to get my values on the same row. Is there a command for that for sprintf? Example how I will have it: 09:03:43 Stefan 123456 end example. 123456 is an integer that is calculated. Thanks for your help, Stefan

    M 1 Reply Last reply
    0
    • S styve

      Hi! I'm using sprintf to get an integer into a string. When I using strcpy I can use strcat to get my values on the same row. Is there a command for that for sprintf? Example how I will have it: 09:03:43 Stefan 123456 end example. 123456 is an integer that is calculated. Thanks for your help, Stefan

      M Offline
      M Offline
      Michael P Butler
      wrote on last edited by
      #2

      sprintf(szBuffer, "09:03:43 Stefan %d", nMyValue); or if nMyValue is a long sprintf(szBuffer, "09:03:43 Stefan %ld", nMyValue); or if the other values are also variable sprintf(szBuffer, "%s %s %ld", szTime, szName, nMyValue); Michael But you know when the truth is told, That you can get what you want or you can just get old, Your're going to kick off before you even get halfway through. When will you realise... Vienna waits for you? - "The Stranger," Billy Joel

      S 1 Reply Last reply
      0
      • M Michael P Butler

        sprintf(szBuffer, "09:03:43 Stefan %d", nMyValue); or if nMyValue is a long sprintf(szBuffer, "09:03:43 Stefan %ld", nMyValue); or if the other values are also variable sprintf(szBuffer, "%s %s %ld", szTime, szName, nMyValue); Michael But you know when the truth is told, That you can get what you want or you can just get old, Your're going to kick off before you even get halfway through. When will you realise... Vienna waits for you? - "The Stranger," Billy Joel

        S Offline
        S Offline
        styve
        wrote on last edited by
        #3

        Thank you! it was "ld" I missed.

        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