my first project, A question

This is a discussion on my first project, A question within the C++ Programming forums, part of the General Programming Boards category; whats not working here its meant to make a text file that goes: admin forceclass 1 spr " " 2 ...

  1. #1
    The N00b That Owns You!
    Join Date
    Jul 2005
    Location
    Canada!
    Posts
    178

    my first project, A question

    whats not working here its meant to make a text file that goes:
    admin forceclass 1 spr
    " " 2 spr
    3 spr etc uip to 2000

    im getin all kinds of errors wont compile

    the type is at users discretion

    Code:
    #include <fstream>
    #include <iostream>
    #include <cstring>
    #include <windows.h>
    
    using namespace std;
    
    int main()
    {
    
        char cont[3];
        char type[7];
        
        cout << "this is the americas army admin forceclass file maker.\n";
        sleep(60);
        cout << "this will make a .txt file anywere you have this program.\n";
        sleep(60);
        cout << "i suggest you have this program on your desktop so the file will show up on your desktop.\n";
        sleep(60);
        cout << "if this file is in a folder the .txt file will appear in the folder this program is in.\n";
        sleep(60);
        cout << "Copyright Richard Wilson, made with the Dev-C++ Compiler Code supplied/created by Richard Wilson, all rights reserved\n\n";
        sleep(60);
        cout << " do you wish to continue (y or n) \n";
        sleep(60);
        cout << "Enter: ";
        cin.getline ( cont, 3 );
        if ( strcmp ( cont, "n" ) == 0 ) {
             cout << "\npress enter to exit...";
             cin.get();
        }
        else if ( strcmp ( cont, "y" ) == 0 ) {
             cout << "\n what type of forceclass will it be?\n";
             cout << " exaple spr rpg m4a1 s24 sf etc. to be forceclassed.\n";
             cout << "    NOTE: this will also be the file name if you choose spr the file will be spr.txt!\n";
             cout << "please enter the type: ";
             cin.getline ( type, 7 );
             cout << "n\ Thank you, please wait wile your file is created.....";
             ofstream forceclass ( ""<< 'type' <<".txt" );
             
             if ( forceclass.is_open() ) {
                  for ( int x = 1; x < 2001; ++x ) {
                      forceclass << "admin forceclass "<< x << 'type' <<"\n";
                      sleep(300);
                      cout << "\n File Succesfully Created! Press Enter!\n";
                      forceclass.close();
                      cin.ignore();              
                  };
                  else {
                       sleep(300);
                       cout << "\n File Cannot Be Created, Press Enter\n";
                       cin.ignore();
                  }
             }
        cout << "This File (if created) will be located in the direcotry as previously described\n";
        cout << "Copyright Richard Wilson 2005\n";
        cout << "Contact Me at deathbydesire101@gmail.com if you discover any bugs...\n";
        cout << " Press Enter\n";
        cin.ignore();
        }
        cout << " quit the program by pressing enter\n";
        cout << "\n\n\n                         Thank You!";
        cin.get();
    }
    help plz
    Last edited by C+noob; 07-06-2005 at 10:34 PM.

  2. #2
    The N00b That Owns You!
    Join Date
    Jul 2005
    Location
    Canada!
    Posts
    178
    and the first sleep(60) it says its undeclared

    this is my first C++ project and i will distribute this...

    i want it to work badly!! ill give credits to the people who help me in the program. THANKS!
    Last edited by C+noob; 07-06-2005 at 10:33 PM. Reason: adding reason

  3. #3
    Banned
    Join Date
    Jun 2005
    Posts
    594
    that because C++ is case senstive, try Sleep(60);

  4. #4
    The N00b That Owns You!
    Join Date
    Jul 2005
    Location
    Canada!
    Posts
    178
    Code:
    #include <fstream>
    #include <iostream>
    #include <cstring>
    #include <windows.h>
    
    using namespace std;
    
    int main()
    {
    
        char cont[3];
        char type[7];
        
        cout << "this is the americas army admin forceclass file maker.\n";
        Sleep(60);
        cout << "this will make a .txt file anywere you have this program.\n";
        Sleep(60);
        cout << "i suggest you have this program on your desktop so the file will show up on your desktop.\n";
        Sleep(60);
        cout << "if this file is in a folder the .txt file will appear in the folder this program is in.\n";
        Sleep(60);
        cout << "Copyright Richard Wilson, made with the Dev-C++ Compiler Code supplied/created by Richard Wilson, all rights reserved\n\n";
        Sleep(60);
        cout << " do you wish to continue (y or n) \n";
        Sleep(60);
        cout << "Enter: ";
        cin.getline ( cont, 3 );
        if ( strcmp ( cont, "n" ) == 0 ) {
             cout << "\npress enter to exit...";
             cin.get();
        }
        else if ( strcmp ( cont, "y" ) == 0 ) {
             cout << "\n what type of forceclass will it be?\n";
             cout << " exaple spr rpg m4a1 s24 sf etc. to be forceclassed.\n";
             cout << "    NOTE: this will also be the file name if you choose spr the file will be spr.txt!\n";
             cout << "please enter the type: ";
             cin.getline ( type, 7 );
             cout << "n\ Thank you, please wait wile your file is created.....";
             ofstream forceclass ( ""<< 'type' <<".txt" );
             
             if ( forceclass.is_open() ) {
                  for ( int x = 1; x < 2001; ++x ) {
                      forceclass << "admin forceclass "<< x << 'type' <<"\n";
                      Sleep(300);
                      cout << "\n File Succesfully Created! Press Enter!\n";
                      forceclass.close();
                      cin.ignore();              
                  };
                  else {
                       Sleep(300);
                       cout << "\n File Cannot Be Created, Press Enter\n";
                       cin.ignore();
                  }
             }
        cout << "This File (if created) will be located in the direcotry as previously described\n";
        cout << "Copyright Richard Wilson 2005\n";
        cout << "Contact Me at deathbydesire101@gmail.com if you discover any bugs...\n";
        cout << " Press Enter\n";
        cin.ignore();
        }
        cout << " quit the program by pressing enter\n";
        cout << "\n\n\n                         Thank You!";
        cin.get();
    }
    lol eliminated that error but it still has eroors i dont know whats wrong trid everythin.

  5. #5
    Banned
    Join Date
    Jun 2005
    Posts
    594
    well i dont have access to my compiler right at the minute and i
    dont feel liek scanning your code visually, lol sorry,
    so if you could paste your error i will be glad to help.

    Oh btw one error i noticed is after a for loop close brackets, you dont need a ';' , just the brackets.

  6. #6
    The N00b That Owns You!
    Join Date
    Jul 2005
    Location
    Canada!
    Posts
    178
    Quote Originally Posted by ILoveVectors
    well i dont have access to my compiler right at the minute and i
    dont feel liek scanning your code visually, lol sorry,
    so if you could paste your error i will be glad to help.

    Oh btw one error i noticed is after a for loop close brackets, you dont need a ';' , just the brackets.
    i have to write it out

    Line Error
    38:18 warning
    39:37 warning multi-character charecter constant
    in function int main()
    39 invalid operands of types const char[1] and int to binary operator>>
    43:60 warning multi-character charcter constant
    49 expected primary-expression before else
    49 expected ; before else



    there i think lol

  7. #7
    *this
    Join Date
    Mar 2005
    Posts
    498
    You can't do this:
    Code:
    ofstream forceclass ( ""<< 'type' <<".txt" );
    You will have to add .txt to your file name and end up with just the file name.
    Code:
    ofstream forceclass ( fileName );
    I suggest reading up on File I/O and strings
    Last edited by JoshR; 07-06-2005 at 11:25 PM.

  8. #8
    *this
    Join Date
    Mar 2005
    Posts
    498
    Also
    Code:
    forceclass << "admin forceclass "<< x << 'type' <<"\n";
    You are trying to output the char of an array pointer...Not so good.

    I really would suggest using strings it would make it so much easier to learn and harder to mess up.

  9. #9
    Banned
    Join Date
    Jun 2005
    Posts
    594
    I went thru it and got rid of your errors, i didnt test it,
    so you will have to tell me if it working as you expected,
    but if you want to learn c++, then you should stop with
    the ways of 'C' and learn things like this :

    http://www.msoe.edu/eecs/ce/courseinfo/stl/string.htm

    Code:
    #include <fstream>
    #include <iostream>
    #include <cstring>
    #include <windows.h>
    
    using namespace std;
    
    int main()
    {
    
        char cont[3];
        char type[7];
        
        cout << "this is the americas army admin forceclass file maker.\n";
        Sleep(60);
        cout << "this will make a .txt file anywere you have this program.\n";
        Sleep(60);
        cout << "i suggest you have this program on your desktop so the file will show up on your desktop.\n";
        Sleep(60);
        cout << "if this file is in a folder the .txt file will appear in the folder this program is in.\n";
        Sleep(60);
        cout << "Copyright Richard Wilson, made with the Dev-C++ Compiler Code supplied/created by Richard Wilson, all rights reserved\n\n";
        Sleep(60);
        cout << " do you wish to continue (y or n) \n";
        Sleep(60);
        cout << "Enter: ";
        cin.getline ( cont, 3 );
        if ( strcmp ( cont, "n" ) == 0 ) 
    	{
             cout << "\npress enter to exit...";
             cin.get();
        }
        else if ( strcmp ( cont, "y" ) == 0 ) 
    	{
             cout << "\n what type of forceclass will it be?\n";
             cout << " exaple spr rpg m4a1 s24 sf etc. to be forceclassed.\n";
             cout << "    NOTE: this will also be the file name if you choose spr the file will be spr.txt!\n";
             cout << "please enter the type: ";
             cin.getline ( type, 7 );
             cout << "\n Thank you, please wait wile your file is created.....";
    		 strcat(type, ".txt");
             ofstream forceclass(type);
             
             if ( forceclass.is_open() ) 
    		 {
                  for ( int x = 1; x < 2001; ++x ) 
    			  {
                      forceclass << "admin forceclass "<< x << 'type' <<"\n";
                      Sleep(300);
                      cout << "\n File Succesfully Created! Press Enter!\n";
                      forceclass.close();
                      cin.ignore();              
                  }
    		 }
             else
    		 {
                  Sleep(300);
                  cout << "\n File Cannot Be Created, Press Enter\n";
                  cin.ignore();
             }
        cout << "This File (if created) will be located in the direcotry as previously described\n";
        cout << "Copyright Richard Wilson 2005\n";
        cout << "Contact Me at deathbydesire101@gmail.com if you discover any bugs...\n";
        cout << " Press Enter\n";
        cin.ignore();
        }
        cout << " quit the program by pressing enter\n";
        cout << "\n\n\n                         Thank You!";
        cin.get();
    }

  10. #10
    The N00b That Owns You!
    Join Date
    Jul 2005
    Location
    Canada!
    Posts
    178
    it com[piled but there is a warning that comes with
    Code:
    forceclass << "admin forceclass "<< x << 'type' <<"\n";
    multi-charecter charecter constant the program compiles and runs until it gets to fil successfully created! press enter once you press enter it just says it again andd again and so on...
    the file created was rpg but the thing is it had this in it:
    admin forceclass 11954115685
    were shud be sumin like admin forceclass 1 rpg all the way to 2000

    i think, nvm i have no clue

  11. #11
    The N00b That Owns You!
    Join Date
    Jul 2005
    Location
    Canada!
    Posts
    178
    ........ forgot bout strcat lol
    Code:
    strcat(type, ".txt");
    but sstill the above errors

  12. #12
    Banned
    Join Date
    Jun 2005
    Posts
    594
    did you change all the code because i compiled with no errors.

  13. #13
    The N00b That Owns You!
    Join Date
    Jul 2005
    Location
    Canada!
    Posts
    178
    yes copied n paste but i get errors when i run the damn thing and a warning wheni compile it i get how u did it (forgot bout strcat) just its malfunctioning lol i examined it it must be the input to forceclass i dont get it though and why when it gets to File Has Been Created Succesfully it repeats itself when u press enter :S

  14. #14
    The N00b That Owns You!
    Join Date
    Jul 2005
    Location
    Canada!
    Posts
    178
    is it because i have ' around type? or should i have a pair of << when i enter those things

  15. #15
    The N00b That Owns You!
    Join Date
    Jul 2005
    Location
    Canada!
    Posts
    178
    Compiler/IDE : Visual Studio .NET 2003 Architect
    can i get a copy for free legally?

Page 1 of 2 12 LastLast
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, 02:12 AM
  2. MSVC project question
    By l2u in forum Windows Programming
    Replies: 2
    Last Post: 03-28-2007, 11:45 AM
  3. application project
    By featherflutter in forum C++ Programming
    Replies: 2
    Last Post: 06-26-2004, 12:12 PM
  4. Please, suggest a project .
    By Dragon227Slayer in forum C# Programming
    Replies: 1
    Last Post: 06-12-2004, 12:16 PM
  5. Very simple question, problem in my Code.
    By Vber in forum C Programming
    Replies: 7
    Last Post: 11-16-2002, 03:57 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21