Solved

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

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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Article by: SunnyDark
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
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…
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++.

732 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