Solved

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

Posted on 2000-02-15
2
266 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

724 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