Solved

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

Posted on 2000-02-15
2
257 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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Often, when implementing a feature, you won't know how certain events should be handled at the point where they occur and you'd rather defer to the user of your function or class. For example, a XML parser will extract a tag from the source code, wh…
  Included as part of the C++ Standard Template Library (STL) is a collection of generic containers. Each of these containers serves a different purpose and has different pros and cons. It is often difficult to decide which container to use and …
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…

786 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