Solved

Multiple File Output in C++ using g++ under Linvux

Posted on 2000-02-15
2
256 Views
Last Modified: 2008-03-06
I am working on a research project in neural networks and need to be able to output sequentially numbered multiple files. I have a loop which performs calculations on an array and outputs a new array. I need to be able to write this array to a different file each time the calculation is performed, preferably sequentially numbered. I have done this about a year ago in Windows but I lost the source and none of my books even touch upon the subject. This is probably a really simple thing to do and I apologise for time wasting, but there is fifty points in it! Cheers.
0
Comment
Question by:bobhope021500
2 Comments
 
LVL 22

Accepted Solution

by:
nietod earned 50 total points
ID: 2523986
just create different "numbere " names for the file and store the names in a  string and then use this name when you open the file, like

for (int i = 0; i< 10; ++i)
{
   char FilNam[13];

   sprintf(FilNam,"File%i.txt",i)

   fstream Fil(FilNam,ios_base::out);
}

Let me know if you have any questions.
0
 

Author Comment

by:bobhope021500
ID: 2527020
Nice! A bit of tweaking and it works very well. Thank you.
--------------_4D4800CEE988BFFFEF34
Content-Disposition: form-data; name="qid"

10295668
--------------_4D4800CEE988BFFFEF34
Content-Disposition: form-data; name="Submit"

Submit
--------------_4D4800CEE988BFFFEF34--
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

IntroductionThis article is the second in a three part article series on the Visual Studio 2008 Debugger.  It provides tips in setting and using breakpoints. If not familiar with this debugger, you can find a basic introduction in the EE article loc…
Introduction This article is a continuation of the C/C++ Visual Studio Express debugger series. Part 1 provided a quick start guide in using the debugger. Part 2 focused on additional topics in breakpoints. As your assignments become a little more …
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

864 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now