By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,260 Members | 1,340 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,260 IT Pros & Developers. It's quick & easy.

textfile

P: n/a
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
Jul 22 '05 #1
Share this Question
Share on Google+
7 Replies


P: n/a
BjoernJackschina schrieb:
What is the source code for this example?


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)
Jul 22 '05 #2

P: n/a
BjoernJackschina wrote:

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?


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
kb******@gascad.at
Jul 22 '05 #3

P: n/a
BjoernJackschina schrieb:
What is the source code for this example?

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)
Jul 22 '05 #4

P: n/a
BjoernJackschina wrote:
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


Is this a homework question?
Jul 22 '05 #5

P: n/a
BjoernJackschina wrote:
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?


Read any C++ book and find the section on file I/O.
Jul 22 '05 #6

P: n/a

"BjoernJackschina" <ja*******@hotmail.com> wrote in message
news:a2**************************@posting.google.c om...
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


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

john
Jul 22 '05 #7

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

int main()
{
ofstream outfile;

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

return 0;
}
"BjoernJackschina" <ja*******@hotmail.com> wrote in message
news:a2**************************@posting.google.c om...
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

Jul 22 '05 #8

This discussion thread is closed

Replies have been disabled for this discussion.