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. Problem with fopen

Problem with fopen

Scheduled Pinned Locked Moved C / C++ / MFC
help
3 Posts 3 Posters 1 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.
  • M Offline
    M Offline
    Maynka
    wrote on last edited by
    #1

    Hi all, I am facing problem in creating a file and writing to it. The code looks like this: TCHAR path[50]; fpLog = fopen((LPCSTR)path,"wt+"); When i am storing some predefined path in variable path.In this case the file is not created in the directory when fopen is executed but when i directly give path e.g D:\\file.txt the file is created and written also. May be i am wrong in executing fopen. Regards,

    C D 2 Replies Last reply
    0
    • M Maynka

      Hi all, I am facing problem in creating a file and writing to it. The code looks like this: TCHAR path[50]; fpLog = fopen((LPCSTR)path,"wt+"); When i am storing some predefined path in variable path.In this case the file is not created in the directory when fopen is executed but when i directly give path e.g D:\\file.txt the file is created and written also. May be i am wrong in executing fopen. Regards,

      C Offline
      C Offline
      codeII
      wrote on last edited by
      #2

      try _tfopen without casting a TCHAR to a char

      1 Reply Last reply
      0
      • M Maynka

        Hi all, I am facing problem in creating a file and writing to it. The code looks like this: TCHAR path[50]; fpLog = fopen((LPCSTR)path,"wt+"); When i am storing some predefined path in variable path.In this case the file is not created in the directory when fopen is executed but when i directly give path e.g D:\\file.txt the file is created and written also. May be i am wrong in executing fopen. Regards,

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

        Maynka wrote:

        When i am storing some predefined path in variable path.In this case the file is not created in the directory when fopen is executed but when i directly give path e.g D:\\file.txt the file is created and written also.

        Are you confusing an absolute path with a relative path?


        "A good athlete is the result of a good and worthy opponent." - David Crow

        "To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne

        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