Solved

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

Posted on 2000-02-15
2
253 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
Comment Utility
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
Comment Utility
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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Unlike C#, C++ doesn't have native support for sealing classes (so they cannot be sub-classed). At the cost of a virtual base class pointer it is possible to implement a pseudo sealing mechanism The trick is to virtually inherit from a base class…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

762 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

14 Experts available now in Live!

Get 1:1 Help Now