View Single Post
Old Mar 9th, 2006, 11:11 AM   #16
HaCkeR
Hobbyist Programmer
 
HaCkeR's Avatar
 
Join Date: Nov 2005
Location: UK
Posts: 131
Rep Power: 0 HaCkeR is an unknown quantity at this point
Send a message via AIM to HaCkeR Send a message via MSN to HaCkeR
OK well thanks guys you all help in some way as ive cracked it now, althought i don't need it right now. Heres what i got. Ow i need to check for file opening but i can do that ive got the actual jo done so here it is

#include <iostream>
#include <fstream>
#include <sstream>
#include <string>

using namespace std;

int main()
{
  stringstream ss;
  string fileName, baseName, baseExt;
  int i, num;
  fstream outPut;
  
  cout << "Enter File name: ";
  getline(cin, baseName);
  cout << "Enter File EXT: ";
  getline(cin, baseExt);
  cout << "Enter Amount Of File: ";
  cin >> num;
  
  while (num > 0)
  {
      num--;
      i++;          
      ss << baseName << i << baseExt << endl;
      getline(ss, fileName);
      outPut.open (fileName.c_str(), ios::binary | ios::out);
      outPut << "Hello";
      outPut.close ();
      cout << "File " << i << " created" << endl;
      }
  cout << "\n All files created thank you, press 'Enter' to exit" << endl;
  
  cin.sync();
  cin.get();
  return 0;
}

I added the same text to each file because thats what it was originally needed for.
HaCkeR is offline   Reply With Quote