Thread: my first project, A question

  1. #16
    Banned
    Join Date
    Jun 2005
    Posts
    594
    Not that i know of, you can get 2005 Beta for free
    i think if they still offer it.

  2. #17
    Banned
    Join Date
    Jun 2005
    Posts
    594
    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.

  3. #18
    The N00b That Owns You!
    Join Date
    Jul 2005
    Location
    Canada!
    Posts
    178
    yea well it screws up the file and puts that one line

  4. #19
    Banned
    Join Date
    Jun 2005
    Posts
    594
    ok for me to better help you i need to knwo what the file
    is suppose to look like when the program finishes running.

  5. #20
    The N00b That Owns You!
    Join Date
    Jul 2005
    Location
    Canada!
    Posts
    178
    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

  6. #21
    *this
    Join Date
    Mar 2005
    Posts
    498
    Quote Originally Posted by C+noob
    is it because i have ' around type? or should i have a pair of << when i enter those things
    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.

    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];
    }

  7. #22
    The N00b That Owns You!
    Join Date
    Jul 2005
    Location
    Canada!
    Posts
    178
    i have no clue how i would implement that into my code?!?!?!?

  8. #23
    Banned
    Join Date
    Jun 2005
    Posts
    594
    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.

  9. #24
    The N00b That Owns You!
    Join Date
    Jul 2005
    Location
    Canada!
    Posts
    178
    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.

  10. #25
    Banned
    Join Date
    Jun 2005
    Posts
    594
    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

    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: ";
    }
    P.S.
    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.

  11. #26
    The N00b That Owns You!
    Join Date
    Jul 2005
    Location
    Canada!
    Posts
    178
    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.

  12. #27
    The N00b That Owns You!
    Join Date
    Jul 2005
    Location
    Canada!
    Posts
    178
    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()?

  13. #28
    Banned
    Join Date
    Jun 2005
    Posts
    594
    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.

  14. #29
    The N00b That Owns You!
    Join Date
    Jul 2005
    Location
    Canada!
    Posts
    178
    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

  15. #30
    Banned
    Join Date
    Jun 2005
    Posts
    594
    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: ";
    }

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Open-source Game Project
    By Glorfindel in forum Projects and Job Recruitment
    Replies: 0
    Last Post: 03-24-2009, 01:12 AM
  2. MSVC project question
    By l2u in forum Windows Programming
    Replies: 2
    Last Post: 03-28-2007, 10:45 AM
  3. application project
    By featherflutter in forum C++ Programming
    Replies: 2
    Last Post: 06-26-2004, 11:12 AM
  4. Please, suggest a project ….
    By Dragon227Slayer in forum C# Programming
    Replies: 1
    Last Post: 06-12-2004, 11:16 AM
  5. Very simple question, problem in my Code.
    By Vber in forum C Programming
    Replies: 7
    Last Post: 11-16-2002, 03:57 PM