Thread: Programing error

  1. #1
    Registered User
    Join Date
    Jun 2007
    Posts
    2

    Programing error

    so far my code looks like
    Code:
    //Coded by: Pwrade//////////////////////
    ////////////////////////////////////////
    /////////////World of warcraft//////////
    /////////////Formulas of Things/////////
    ////////////////////////////////////////
    ////////////////////////////////////////
    #include <iostream>	
    
    using namespace std;
    		
    int main()
    {
        int Select;
        int clvl;
        int ap;
        int Arm;
        
        
        cout<< "==== Version 0.1 Alpha====\n";
        cout<< "=========================\n";
        cout<< "====Coded by: Pwrade=====\n";
        cout<< "==========================\n ";
        cout<< "\n";cout<< "\n";cout<< "\n";cout<< "\n";
        cout<< "0- Attack Power\n";cout<< "1-Damage Reduction\n"; cout<< "2-exp\n";
        cin>> Select;
        cin.ignore();
        if( Select == 0){
        cout<< "Enter Your Attack Power";
        cout<< "\n";
        cin>> ap;
        cin.ignore();
        cout<< " your character does "<< ap/14 << "DPS(w/o weapon)" <<"\n";
        
        if ( Select == 1){
             cout<< " Please enter your Armor";
             
             }
             
        
    }
     cin.get();   
    }
    when i type 1 after i run it though nothing happens then it closes..help plz

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    Indentation is key to figuring out what is going on
    Code:
    #include <iostream>
    
    using namespace std;
    
    int main()
    {
        int Select;
        int clvl;
        int ap;
        int Arm;
        
        cout << "==== Version 0.1 Alpha====\n";
        cout << "=========================\n";
        cout << "====Coded by: Pwrade=====\n";
        cout << "==========================\n ";
        cout << "\n";
        cout << "\n";
        cout << "\n";
        cout << "\n";
        cout << "0- Attack Power\n";
        cout << "1-Damage Reduction\n";
        cout << "2-exp\n";
        cin >> Select;
        cin.ignore();
        if (Select == 0) {
            cout << "Enter Your Attack Power";
            cout << "\n";
            cin >> ap;
            cin.ignore();
            cout << " your character does " << ap /
                14 << "DPS(w/o weapon)" << "\n";
    
            if (Select == 1) { //!! Can never happen, it's inside Select == 0
                cout << " Please enter your Armor";
    
            }
        }
        cin.get();
    }
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  3. #3
    Registered User
    Join Date
    Jun 2007
    Posts
    2
    ahh thx = P didnt see that usually compiler tells me what i did wrong, thx again!

  4. #4
    Registered User
    Join Date
    May 2006
    Posts
    903
    A compiler will never show you logical errors.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Getting an error with OpenGL: collect2: ld returned 1 exit status
    By Lorgon Jortle in forum C++ Programming
    Replies: 6
    Last Post: 05-08-2009, 08:18 PM
  2. An error is driving me nuts!
    By ulillillia in forum C Programming
    Replies: 5
    Last Post: 04-04-2009, 09:15 PM
  3. Making C DLL using MSVC++ 2005
    By chico1st in forum C Programming
    Replies: 26
    Last Post: 05-28-2008, 01:17 PM
  4. Connecting to a mysql server and querying problem
    By Diod in forum C++ Programming
    Replies: 8
    Last Post: 02-13-2006, 10:33 AM
  5. Couple C questions :)
    By Divx in forum C Programming
    Replies: 5
    Last Post: 01-28-2003, 01:10 AM