473,395 Members | 1,941 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

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
Jul 22 '05 #1
7 1465
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
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
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
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
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

"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
// 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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Hans A | last post by:
I have a textfile "textfile.txt" containing a list of words. There is one word on each line. I want to pick two random lines from this textfile, and I have tried to do something like: //Loading...
1
by: Larry Rekow | last post by:
I have a report that's created each day as a flat textfile. Because I came from the Access world, I created a macro that imports it with a schema that gives meaningful names to the various...
1
by: Michael Schindler | last post by:
Ich habe es nun erreicht, ein textfile einzulesen das nun zeile für zeile im datagrid angezeigt wird. Nun wäre es toll wenn ich das textfile zum beispiel nach jedem blank in eine spalte...
4
by: Kevin Johnson | last post by:
Hi Using C# and a textfile I need to do two things: 1. Read the contents of the textfile and return the number of words contained in it. 2. Output a list of unqiue words (i.e. not...
2
by: chris | last post by:
Hi there, I am reading in a textfile which looks like this (there is no new line after the last number) 03 98661881 0407 566453 The code to load the textfile looks like this:
7
by: Peter Proost | last post by:
Hi, I'm creating an import module to read data from old textfiles, run some calculations on them and save them to sql server. I've figured out how to do a select on textfile using a schema.ini file...
8
by: andreas | last post by:
A textfile can have different formats like ANSI,UTF8, Unicode ... Using streamreader for a textfile can have different results for chars like é,à,è....depending of the fileformat. To solve this...
1
by: kachokaratz | last post by:
well i have a problem in my project..since the contents of my textfile is too long, i was wondering how to output the textfile in such a way that you can divide the contents to be able to output...
14
by: blumen | last post by:
Hi all, I'm a newbie in VB.Net Programming.. Hope that some of you can help me to solve this.. I'm working out to read,parse and save textfile into SQL Server. The textfile contains thousands...
1
by: asedt | last post by:
With my Excel macro and two text files I want to create a new textfile containing the first textfile then text from the sheet and then the second textfile. My problem is that i don't know how to...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.