textfile

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • BjoernJackschina

    textfile

    Hello,
    I just want to write something in a textfile. It should have this structure:
    word "\t" word1 "\n"
    word2 "\t" word3 "\n"
    and so on.
    What is the source code for this example?
    Many thanks
  • marbac

    #2
    Re: textfile

    BjoernJackschin a schrieb:
    [color=blue]
    > What is the source code for this example?[/color]

    I don't think, that someone here will write you the requested code.

    google for ofstream
    (ofstream class provides a stream interface to write data to files)

    Comment

    • Karl Heinz Buchegger

      #3
      Re: textfile

      BjoernJackschin a wrote:[color=blue]
      >
      > Hello,
      > I just want to write something in a textfile. It should have this structure:
      > word "\t" word1 "\n"
      > word2 "\t" word3 "\n"
      > and so on.
      > What is the source code for this example?[/color]

      it is pretty much the same as if you write the thing
      to cout.
      Just replace cout with a variable of type ofstream.

      Which books are you using?


      --
      Karl Heinz Buchegger
      kbuchegg@gascad .at

      Comment

      • marbac

        #4
        Re: textfile

        BjoernJackschin a schrieb:
        [color=blue]
        > What is the source code for this example?[/color]


        I don't think, that someone here will write the requested code for you.

        google for ofstream
        (ofstream class provides a stream interface to write data to files)

        Comment

        • Jeff Schwab

          #5
          Re: textfile

          BjoernJackschin a wrote:[color=blue]
          > Hello,
          > I just want to write something in a textfile. It should have this structure:
          > word "\t" word1 "\n"
          > word2 "\t" word3 "\n"
          > and so on.
          > What is the source code for this example?
          > Many thanks[/color]

          Is this a homework question?

          Comment

          • Bill Seurer

            #6
            Re: textfile

            BjoernJackschin a wrote:
            [color=blue]
            > I just want to write something in a textfile. It should have this structure:
            > word "\t" word1 "\n"
            > word2 "\t" word3 "\n"
            > and so on.
            > What is the source code for this example?[/color]

            Read any C++ book and find the section on file I/O.

            Comment

            • John Harrison

              #7
              Re: textfile


              "BjoernJackschi na" <jacksch_1@hotm ail.com> wrote in message
              news:a24000a2.0 405110300.52ec6 400@posting.goo gle.com...[color=blue]
              > Hello,
              > I just want to write something in a textfile. It should have this[/color]
              structure:[color=blue]
              > word "\t" word1 "\n"
              > word2 "\t" word3 "\n"
              > and so on.
              > What is the source code for this example?
              > Many thanks[/color]

              file << word << "\t" << word1 << "\n" << word2 << "\t" << word3 << "\n";

              john


              Comment

              • Jakob Olsen

                #8
                Re: textfile

                // ofstream::open
                #include <fstream>
                using namespace std;

                int main()
                {
                ofstream outfile;

                outfile.open ("test.txt", ofstream::out | ofstream::app);
                outfile << "WORD1\tNAVN1\n WORD2\tNAVN2\n" ;
                outfile.close() ;

                return 0;
                }
                "BjoernJackschi na" <jacksch_1@hotm ail.com> wrote in message
                news:a24000a2.0 405110300.52ec6 400@posting.goo gle.com...[color=blue]
                > Hello,
                > I just want to write something in a textfile. It should have this[/color]
                structure:[color=blue]
                > word "\t" word1 "\n"
                > word2 "\t" word3 "\n"
                > and so on.
                > What is the source code for this example?
                > Many thanks[/color]


                Comment

                Working...