Hi all, I have managed to find a IntToString algorithm and I THINK its working, however the files are not generating. Sigh. If you could look over my code that would be great!
#include <string>
#include <cstring>
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <stdlib.h>
#include <string>
using namespace std;
string IntToString(unsigned int x)
{
static const int Radix = 10;
static const int MaxDigits = 20;
if (0 == x) return "0";
char Tmp[MaxDigits + 1];
char* Cur = Tmp + MaxDigits;
*Cur = '\0';
while (x && (Cur > Tmp))
{
--Cur;
*Cur = (x%Radix) + '0';
x /= Radix;
}
return Cur;
}
int main(int argcount, char* args[]){
int number_of_arguments = argcount-1;
for (int i=1;i<=number_of_arguments;i++){
string argTemp = args[i];
if (argTemp == "-d"){
cout<<"sup"<<endl;
//begin loop
string classSize,increm;
for (int i=0;i<3;i++){
cout<<i<<endl;
if (i==0){
classSize="102";increm="100";}
if (i==1){classSize="1024";increm="1000";}
if (i==2){classSize="10240";increm="10000";}
if (i==3){classSize="102400";increm="100000";}
int incremTEMP=atoi(increm.c_str());
int classSizeTEMP=atoi(classSize.c_str());
for (int j=0;j<9;j++){
string dest=args[2];
dest=dest+"/class"+classSize+"_"+increm;
ofstream myfile (dest.c_str());
cout<<dest<<endl;
cout<<increm<<endl;
if (!myfile.is_open()) { //check validity of file
cerr << "Error: cannot open the file " << dest << endl;
exit (-1);
}else{
for (int k=0;k<(classSizeTEMP+incremTEMP)/2;k++){
myfile<<"LO";
}
}
myfile.close();
incremTEMP=incremTEMP+(j+1)*incremTEMP;
increm=IntToString(incremTEMP);
}
}
}
}
}
Last edited by Eyies : Mar 30th, 2007 at 1:03 am.