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. write to a text file

write to a text file

Scheduled Pinned Locked Moved C / C++ / MFC
help
14 Posts 6 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.
  • C Cedric Moonen

    What's the problem. See point 2 here[^]


    Cédric Moonen Software developer
    Charting control [v1.2]

    T Offline
    T Offline
    tasumisra
    wrote on last edited by
    #4

    i am just trying to write a text file to some specified path... that will contain some string data .... as an example.. if i have a string "hii i am here in code project" so this will be written there in the text file (text file will be created from code) please help out me here Thanks in advance

    vikas

    1 Reply Last reply
    0
    • H Hamid Taebi

      You can use of CFile class for read and write.

      T Offline
      T Offline
      tasumisra
      wrote on last edited by
      #5

      Thanks Hamid, i think this is inbuild class but i want to do this by code just like... 1. create a text file 2.Open the file in read/write mode 3.append the text/write the text 4.close the file thanks alot guys for help

      vikas

      C 1 Reply Last reply
      0
      • T tasumisra

        Thanks Hamid, i think this is inbuild class but i want to do this by code just like... 1. create a text file 2.Open the file in read/write mode 3.append the text/write the text 4.close the file thanks alot guys for help

        vikas

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

        tasumisra wrote:

        i think this is inbuild class

        :confused: What ? You can perfectly use CFile in your code, what's the problem ? Just look in MSDN how to use the class.


        Cédric Moonen Software developer
        Charting control [v1.2]

        T 1 Reply Last reply
        0
        • C Cedric Moonen

          tasumisra wrote:

          i think this is inbuild class

          :confused: What ? You can perfectly use CFile in your code, what's the problem ? Just look in MSDN how to use the class.


          Cédric Moonen Software developer
          Charting control [v1.2]

          T Offline
          T Offline
          tasumisra
          wrote on last edited by
          #7

          i dont want to use class CFile : public CObject BECAUSE i am writing a COM component in that i need to put some log so there i cant use CFILE may be it can be used there but i dont know.. so please help me in this context Thanks...

          vikas

          C D 2 Replies Last reply
          0
          • T tasumisra

            i dont want to use class CFile : public CObject BECAUSE i am writing a COM component in that i need to put some log so there i cant use CFILE may be it can be used there but i dont know.. so please help me in this context Thanks...

            vikas

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

            Use a std::ofstream instead. #include using namespace std; ... ... ofstream MyFile("Output.txt"); MyFile << "Hello World" << endl;


            Cédric Moonen Software developer
            Charting control [v1.2]

            T 1 Reply Last reply
            0
            • C Cedric Moonen

              Use a std::ofstream instead. #include using namespace std; ... ... ofstream MyFile("Output.txt"); MyFile << "Hello World" << endl;


              Cédric Moonen Software developer
              Charting control [v1.2]

              T Offline
              T Offline
              tasumisra
              wrote on last edited by
              #9

              Thanks for your help i ll check it..

              vikas

              K 1 Reply Last reply
              0
              • T tasumisra

                Thanks for your help i ll check it..

                vikas

                K Offline
                K Offline
                Kenan Aksoy
                wrote on last edited by
                #10

                use these win32 API's CreateFile,WriteFile

                dlfkgj lsdfkglfkgjlfgl jldfk fldkk jk

                1 Reply Last reply
                0
                • T tasumisra

                  Hi all , i am trying to write a text file to a given location like c:\abc.txt can anybody help me here.. Thanks in adavnce

                  vikas

                  M Offline
                  M Offline
                  Maximilien
                  wrote on last edited by
                  #11

                  What about FILE and fopen ?


                  Maximilien Lincourt Your Head A Splode - Strong Bad

                  1 Reply Last reply
                  0
                  • T tasumisra

                    i dont want to use class CFile : public CObject BECAUSE i am writing a COM component in that i need to put some log so there i cant use CFILE may be it can be used there but i dont know.. so please help me in this context Thanks...

                    vikas

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

                    tasumisra wrote:

                    i am writing a COM component...

                    Which is an advanced topic. If writing to a text file is troubling you, COM will be next to impossible.

                    tasumisra wrote:

                    ...may be it can be used there...

                    Certainly it can, but that's irrelevant at this point.


                    "Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman

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

                    T 1 Reply Last reply
                    0
                    • D David Crow

                      tasumisra wrote:

                      i am writing a COM component...

                      Which is an advanced topic. If writing to a text file is troubling you, COM will be next to impossible.

                      tasumisra wrote:

                      ...may be it can be used there...

                      Certainly it can, but that's irrelevant at this point.


                      "Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman

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

                      T Offline
                      T Offline
                      tasumisra
                      wrote on last edited by
                      #13

                      DavidCrow wrote:

                      COM will be next to impossible

                      NO BODY is there who knows COM BY BIRTH .... here only everybody had learnt and me too... will prove it...

                      vikas

                      D 1 Reply Last reply
                      0
                      • T tasumisra

                        DavidCrow wrote:

                        COM will be next to impossible

                        NO BODY is there who knows COM BY BIRTH .... here only everybody had learnt and me too... will prove it...

                        vikas

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

                        tasumisra wrote:

                        will prove it...

                        Good luck.


                        "Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman

                        "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