•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the C++ section within the Software Development category of DaniWeb, a massive community of 423,546 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 4,026 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our C++ advertiser: Programming Forums
Views: 698 | Replies: 2 | Solved
•
•
Join Date: Mar 2007
Posts: 3
Reputation:
Rep Power: 0
Solved Threads: 0
Hey all, I'm new to this forum, first post.. so please excuse me (also excuse the perhaps not so eloquent style, it is still in preliminary!) =). I'm writing a short piece of code in compliance with a webserver I've been programming with a group. This code is to auto generate an assorted sizes of files (which will later be used to test latency timings and average GET request timings) starting from size Class 0 which are files less
than 1KB, class 1 files are less than 10K, class 2 files are less than 100K and class 3 files
are less than 1MB. It should auto-populates the specified directory with the four
classes of files. There will be 9 files per class. Files in class 0 are in increments of
0.1KB (starting at 102 bytes) while class 1, class 2 and class 3 are in increments of 1KB. Syntax to use the code is HTMLGenerator -d <directory>. Output files should have the form of class<classsize#>_<increment>.
My greatest problem is that our school's compiler is old and does not contain <sstream> hence making my INT to String conversion difficult. Currently the code seg faults, likely due to improper usage of the *buffer. Any questions regarding the code I will promptly reply as I'm still working away. Any suggestions on how I can get this done? Thank you all greatly for your time and help ! =)
than 1KB, class 1 files are less than 10K, class 2 files are less than 100K and class 3 files
are less than 1MB. It should auto-populates the specified directory with the four
classes of files. There will be 9 files per class. Files in class 0 are in increments of
0.1KB (starting at 102 bytes) while class 1, class 2 and class 3 are in increments of 1KB. Syntax to use the code is HTMLGenerator -d <directory>. Output files should have the form of class<classsize#>_<increment>.
My greatest problem is that our school's compiler is old and does not contain <sstream> hence making my INT to String conversion difficult. Currently the code seg faults, likely due to improper usage of the *buffer. Any questions regarding the code I will promptly reply as I'm still working away. Any suggestions on how I can get this done? Thank you all greatly for your time and help ! =)
c++ Syntax (Toggle Plain Text)
#include <string> #include <cstring> #include <iostream> #include <fstream> #include <stdio.h> #include <stdlib.h> #include <string> using namespace std; 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"){ //begin loop string classSize,increm; for (int i=0;i<1;i++){ 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()); 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*incremTEMP; //problems here (i'm really not sure i'm using //sprintf correctly at all, let alone storing the // data in buffer back into increm char *buffer[100]; sprintf(buffer[100], "%d",incremTEMP); for (int i=1;i<=100;i++) increm+=buffer[i]; delete *buffer; } } } } }
Last edited by Eyies : Mar 29th, 2007 at 11:11 pm.
•
•
•
•
•
•
•
•
DaniWeb C++ Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
Similar Threads
- Cygwin file generator (C)
- Header file Generator (C)
- File generator/tracking (IT Technologies and Trends)
Other Threads in the C++ Forum
- Previous Thread: struct functions - lost a wee bit (i hope) in calling the functions
- Next Thread: Why NOT void main()



Threaded Mode