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. Trouble with types...

Trouble with types...

Scheduled Pinned Locked Moved C / C++ / MFC
c++question
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.
  • S Offline
    S Offline
    satcat
    wrote on last edited by
    #1

    I'm trying to write in a file in my .cpp code: I have a TCHAR variable szText and it should be a string so I could write fprintf( fichero, "%s\n", szText); How could I convert my TCHAR in a string? Thank you very much!!!!

    S D 2 Replies Last reply
    0
    • S satcat

      I'm trying to write in a file in my .cpp code: I have a TCHAR variable szText and it should be a string so I could write fprintf( fichero, "%s\n", szText); How could I convert my TCHAR in a string? Thank you very much!!!!

      S Offline
      S Offline
      Selvam R
      wrote on last edited by
      #2

      Hello, http://msdn.microsoft.com/archive/default.asp?url=/archive/en-us/dnarvc/html/msdn\_mbcssg.asp With Regards, R.Selvam

      1 Reply Last reply
      0
      • S satcat

        I'm trying to write in a file in my .cpp code: I have a TCHAR variable szText and it should be a string so I could write fprintf( fichero, "%s\n", szText); How could I convert my TCHAR in a string? Thank you very much!!!!

        D Offline
        D Offline
        David Crow
        wrote on last edited by
        #3

        If szText is a TCHAR, the correct syntax would be:

        fprintf( fichero, "%c\n", szText);

        I assume, however, that you meant that szText was a TCHAR*. Correct? If so, your fprintf() statement is correct.


        A rich person is not the one who has the most, but the one that needs the least.

        S 1 Reply Last reply
        0
        • D David Crow

          If szText is a TCHAR, the correct syntax would be:

          fprintf( fichero, "%c\n", szText);

          I assume, however, that you meant that szText was a TCHAR*. Correct? If so, your fprintf() statement is correct.


          A rich person is not the one who has the most, but the one that needs the least.

          S Offline
          S Offline
          satcat
          wrote on last edited by
          #4

          Thank you, now it's OK :) The real definition was: TCHAR szText[256] = { _T('\0') };

          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