Not that i know of, you can get 2005 Beta for free
i think if they still offer it.
Not that i know of, you can get 2005 Beta for free
i think if they still offer it.
oh also i dont see what malfunction you are getting with
the file creation, i see the creation of the file when i run it,
and the reason it keeps repeating it self is do
to the for loop, maybe a for loop isnt what you had in mind
there.
yea well it screws up the file and puts that one line
ok for me to better help you i need to knwo what the file
is suppose to look like when the program finishes running.
ok i inputed the type as 'rpg' so the file name is rpg.txt it should say:
admin forceclass 1 rpg
admin forceclass 2 rpg
admin forceclass 3 rpg
....
all the way too 2000
type has been declared by you as a char array. Right now you are trying to output the char value of the memorry address. What you want to do is output each letter or if you should chose to use strings and type was declared as a string, then you could just take of the ' and it would worry about outputting it for you.Originally Posted by C+noob
I'm not an expert with C functions and/or utilities so I don't know if there is a function to do this for you but you would have to do:
Code:int SIZE = strlen(type); for (int count = 0; count < SIZE; count++) { forceclass << type[count]; }
i have no clue how i would implement that into my code?!?!?!?
im writing your code voer again in a more c++ like way,
i dont epect you to use it i expect you to learn from
it and possibly see where youd like go go with your next adventure.
Ill be posting it in a minute.
lol im here for personal gain lol im 14 i dont think im takin a university exam on it next monday lol my goal is to learn everything about computers and develop an O/S better than windows later on in life.
OK here is the long awaited code, i did alot of testing,
and learned one thing my self in the process even though
the code is rather simple. like i said i did test it alot,
but i may have missed something im half asleep,
i will be going to bed soon so any question you have,
please ask quickly
P.S.Code:#include <iostream> #include <fstream> #include <string> #include <windows.h> using namespace std; void menu(void); int main(int argc, char *argv[]) { string filelocation = argv[0]; string type; size_t pos = filelocation.find_last_of("\\"); filelocation.erase(pos, (filelocation.size()-pos)); string filename; fstream forceclassfile; menu(); getline(cin, filename, '\n'); type = filename; filename += ".txt"; forceclassfile.open(filename.c_str(), ios::out); if ( !forceclassfile.fail() ) { for(int x = 1; x != 2001; x++) { forceclassfile << "admin forceclass "<< x << " " << type << endl; } cout << "File Succesfully Created! Press Enter!" << endl; cout << "Your file can be found here : " << endl; cout << filelocation << "\\" << filename << endl; forceclassfile.close(); } else { cout << "File Cannot Be Created" << endl; cout << "Program Terminating!" << endl; Sleep(3000); return 2; } cout << "Copyright Richard Wilson 2005\n"; cout << "Contact Me at [email protected] if you discover any bugs...\n"; cout << "Press Enter\n"; cin.get(); return 0; } void menu(void) { cout << "This is the americas army admin forceclass file maker." << endl; cout << "This will make a .txt file anywere you have this program." << endl; cout << "I suggest you have this program on your desktop so the file" << endl; cout << "will show up on your desktop." << endl; cout << "If this file is in a folder the .txt file will appear in the" << endl; cout << "folder this program is in." << endl; cout << "Copyright Richard Wilson, made with the Dev-C++ Compiler Code" << endl; cout << "supplied/created by Richard Wilson, all rights reserved" << endl << endl; cout << "Press Enter when you are ready to continue." << endl; cin.get(); cout << "What type of forceclass will it be?" << endl; cout << "Exsamples :" << endl; cout << "spr rpg m4a1 s24 sf" << endl; cout << "Please enter the type: "; }
If it were for people like C+noob and many other id be bored
out of my mind, so thanks for your post and what not it always
a pleasure to help those that truely want to learn.
Last edited by ILoveVectors; 07-07-2005 at 12:07 AM.
Code:void menu(void); int main(int argc, char *argv[]) { string filelocation = argv[0]; string type; size_t pos = filelocation.find_last_of("\\"); filelocation.erase(pos, (filelocation.size()-pos)); string filename; fstream forceclassfile; menu(); getline(cin, filename, '\n'); type = filename; filename += ".txt"; forceclassfile.open(filename.c_str(), ios::out); if ( !forceclassfile.fail() ) {
what happened to #include <cstring> ?
about all that i quoted means jus basically im doing sumthin ........ off lol rather than this is what im doing lol its nonsense lol ive never seen code like that wow i dont understand any of it.
mgot a good tut sumwere bout this string header and i never have understood the void thing if its making it like god..... if its sayin dont worry about this why are you defining it? and what the hell are those things u put in main()?
well cstring is the devil, beside this is not c we doing c++ so we
use the header string.
most of that stuff is string manipulation which if you look that link
in earlier post will teach you about it.
the fstream object, i declared ahead of time instead of with the
file and i opened it later.
the void menu(void) is a function which when called by menu();
in the main code displays everything in its defintion below main;
the paramter main is taking is for command line arguments,
which all it there for is to let me get the location
of the running program there for allowing me to locate
the location of our outputted file.
Errm oh and void, is used in my function above simply to state
that i wont be returning a value or sending a value to it.
ok?!?! still add me on aim mmk deathbydesire101 or msn [email protected] and yea ill research it its ironic outta all these members lol its always you that seems to ficx my problems :P
will do ill message you right now, btw this is that code commented
Code:#include <iostream> #include <fstream> #include <string> #include <windows.h> using namespace std; void menu(void);//void because im not sending or recieving any values int main(int argc, char *argv[])//command line parameters { string filelocation = argv[0];//save the file location into a string string type; size_t pos = filelocation.find_last_of("\\");//find the location of the last "\" filelocation.erase(pos, (filelocation.size()-pos));//delete everything from the end of the string to the last "\" string filename; fstream forceclassfile; // declare a fstream object menu();// load the function menu declared above getline(cin, filename, '\n'); type = filename; filename += ".txt"; //add .txt to the string forceclassfile.open(filename.c_str(), ios::out);//open the file with the user input if ( !forceclassfile.fail() ) { for(int x = 1; x != 2001; x++) { forceclassfile << "admin forceclass "<< x << " " << type << endl; } cout << "File Succesfully Created! Press Enter!" << endl; cout << "Your file can be found here : " << endl; cout << filelocation << "\\" << filename << endl;//displays the file location forceclassfile.close(); } else { cout << "File Cannot Be Created" << endl; cout << "Program Terminating!" << endl; Sleep(3000); return 2; } cout << "Copyright Richard Wilson 2005\n"; cout << "Contact Me at [email protected] if you discover any bugs...\n"; cout << "Press Enter\n"; cin.get(); return 0; } void menu(void) { cout << "This is the americas army admin forceclass file maker." << endl; cout << "This will make a .txt file anywere you have this program." << endl; cout << "I suggest you have this program on your desktop so the file" << endl; cout << "will show up on your desktop." << endl; cout << "If this file is in a folder the .txt file will appear in the" << endl; cout << "folder this program is in." << endl; cout << "Copyright Richard Wilson, made with the Dev-C++ Compiler Code" << endl; cout << "supplied/created by Richard Wilson, all rights reserved" << endl << endl; cout << "Press Enter when you are ready to continue." << endl; cin.get(); cout << "What type of forceclass will it be?" << endl; cout << "Exsamples :" << endl; cout << "spr rpg m4a1 s24 sf" << endl; cout << "Please enter the type: "; }