Subj : Re: index dependent filename To : borland.public.cpp.borlandcpp From : maeder@glue.ch (Thomas Maeder [TeamB]) Date : Wed Oct 29 2003 07:18 am "cory" writes: > I want to run a loop indexed by an integer (k) several times and output > the data to a different file with each loop. Is there a way to write > print to file statements wth name that depend on the index (k)? For > example how do I write "yahoo on (k)" to file yahoo_k.txt for each index (k). First create the filename depending on k. You can use sprintf() or a string stream (std::ostrstream or std::ostringstream) for this. Then open the file with this dynamically created name. .