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. String Error

String Error

Scheduled Pinned Locked Moved C / C++ / MFC
helptutorial
4 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.
  • J Offline
    J Offline
    John Bosko
    wrote on last edited by
    #1

    Hi, In the below code I've copied the value of a string variable into "store" (which is Char(50). When I print the value of store, it crashes!!! please can someone tell me how to store from string to char and print the value of char!! thanks, John:confused: Code: ====================================================================== strcpy(store,ret.c_str()); printf("%s",store); ======================================================================

    J 1 Reply Last reply
    0
    • J John Bosko

      Hi, In the below code I've copied the value of a string variable into "store" (which is Char(50). When I print the value of store, it crashes!!! please can someone tell me how to store from string to char and print the value of char!! thanks, John:confused: Code: ====================================================================== strcpy(store,ret.c_str()); printf("%s",store); ======================================================================

      J Offline
      J Offline
      jmkhael
      wrote on last edited by
      #2

      what u did is correct, but printf crashes if store == null, check for this Papa while (TRUE) Papa.WillLove ( Bebe ) ;

      S 1 Reply Last reply
      0
      • J jmkhael

        what u did is correct, but printf crashes if store == null, check for this Papa while (TRUE) Papa.WillLove ( Bebe ) ;

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

        In that case, the strcpy would fail too, surely? Steve S [This signature space available for rent]

        J 1 Reply Last reply
        0
        • S Steve S

          In that case, the strcpy would fail too, surely? Steve S [This signature space available for rent]

          J Offline
          J Offline
          jmkhael
          wrote on last edited by
          #4

          oups yes, that's what i meant :) Papa while (TRUE) Papa.WillLove ( Bebe ) ;

          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