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. concatenate strings with long

concatenate strings with long

Scheduled Pinned Locked Moved C / C++ / MFC
tutorial
4 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.
  • I Offline
    I Offline
    identity_85
    wrote on last edited by
    #1

    how to concatenate strings with longs for example if i want to do that: long j=5; MessageBox("the number is"+J+"apples");

    C H P 3 Replies Last reply
    0
    • I identity_85

      how to concatenate strings with longs for example if i want to do that: long j=5; MessageBox("the number is"+J+"apples");

      C Offline
      C Offline
      Cedric Moonen
      wrote on last edited by
      #2

      You can use printf for that:

      char szBuffer[50];
      sprintf(szBuffer,"the number is %i apples",J);

      Take a look at sprintf[^] and format spec[^] in the MSDN for more details.


      Cédric Moonen Software developer
      Charting control

      1 Reply Last reply
      0
      • I identity_85

        how to concatenate strings with longs for example if i want to do that: long j=5; MessageBox("the number is"+J+"apples");

        H Offline
        H Offline
        Hamid Taebi
        wrote on last edited by
        #3

        See CString::Formatand wsprintf(...)

        _**


        **_

        WhiteSky


        1 Reply Last reply
        0
        • I identity_85

          how to concatenate strings with longs for example if i want to do that: long j=5; MessageBox("the number is"+J+"apples");

          P Offline
          P Offline
          Parthi_Appu
          wrote on last edited by
          #4

          Also you can use CString class as, CString str(""); LONG l = 5; str.Format("The Number is %ld Apples", l); MessageBox(str);

          Do your Duty and Don't expect the Result

          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