textfile

B

BjoernJackschina

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
 
M

marbac

BjoernJackschina said:
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)
 
K

Karl Heinz Buchegger

BjoernJackschina said:
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?
 
M

marbac

BjoernJackschina said:
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)
 
J

Jeff Schwab

BjoernJackschina said:
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?
 
B

Bill Seurer

BjoernJackschina said:
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.
 
J

John Harrison

BjoernJackschina said:
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
 
J

Jakob Olsen

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

int main()
{
ofstream outfile;

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

return 0;
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,777
Messages
2,569,604
Members
45,226
Latest member
KristanTal

Latest Threads

Top