functuions and variables

This is a discussion on functuions and variables within the C++ Programming forums, part of the General Programming Boards category; i have a part in my code that goes void menuscreen(void); witch supposily goes to Code: void menuscreen(void) { if ...

  1. #1
    Sir Mister Insane Sako Klinerr1's Avatar
    Join Date
    May 2002
    Posts
    608

    functuions and variables

    i have a part in my code that goes


    void menuscreen(void);

    witch supposily goes to
    Code:
    void menuscreen(void)
    {
    if (charactertype == 1){
    cout << "&&&&&&&&&&&-MENU-&&&&&&&&&&&&&&                   *"<<endl;
    cout << "&                             &                    **"<<endl;
    cout << "&  1. Resume Game             &                     ****"<<endl;
    cout << "&                             &       ****          *******"<<endl;
    cout << "&                             &      *    *       *********"<<endl;
    cout << "&  2. Save Game               &      *    *     *************"<<endl;
    cout << "&                             &       ****     *****************"<<endl;
    cout << "&                             &        **        ##############"<<endl;
    cout << "&  3. View Status             &        **       ####   ##   ####"<<endl;
    cout << "&                             &        **      #####   ##   #####"<<endl;
    cout << "&                             &        **      #####   ##   #####"<<endl;
    cout << "&  4. View Map                &        **       ################"<<endl;
    cout << "&                             &        **        ##############"<<endl;
    cout << "&                             &        **         ############"<<endl;
    cout << "&  5. Go to Main Screen       &        **      %%%%%%%%%%%%%%%%%%%"<<endl;
    cout << "&                             &        **     %%%%%%%%%%%%%%%%%%%%%"<<endl;
    cout << "&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&        **   %%%%%%%%%%%%%%%%%%%%%%%%"<<endl;
    }
    else if (charactertype == 2){
    cout << "&&&&&&&&&&&-MENU-&&&&&&&&&&&&&&  <<<<<<<>>>>>>>>&&&&&&"<<endl;
    cout << "&                             & <<<<<<<<>>>>>>>>>&&&&&&"<<endl;
    cout << "&  1. Resume Game             & <<<<<<<<>>>>>>>>>&&  &&&"<<endl;
    cout << "&                             &  <<<<<<<>>>>>>>>&&&  &&&"<<endl;
    cout << "&                             &        |||   &&&&&&&&&&&"<<endl;
    cout << "&  2. Save Game               &        |||   &&&&&&&&&&&"<<endl;
    cout << "&                             &      %%|||%%  &&&&&&&&&   %%%%%"<<endl;
    cout << "&                             &      eeeeeee%%%%%%%%%%%%%%%%%%%%%"<<endl;
    cout << "&  3. View Status             &      eeeeeee%%%%%%%%%%%%%%%%%%%%%"<<endl;
    cout << "&                             &      eeeeeee%%%%%%%%%%%%%%%%%%%%e"<<endl;
    cout << "&                             &        |||%%%%%%%%%%%%%%%%%%%%eee"<<endl;
    cout << "&  4. View Map                &        |||%%%%%%%%%%%%%%%%%%%eeeee"<<endl;
    cout << "&                             &        |||%%%%%%%%%%%%%%%%%%eeeeeee"<<endl;
    cout << "&                             &        |||%%%%%%%%%%%%%%%%%%eeeeeee"<<endl;
    cout << "&  5. Go to Main Screen       &        |||%%%%%%%%%%%%%%%%%%%eeeeee"<<endl;
    cout << "&                             &        |||%%%%%%%%%%%%%%%%%%% eeee"<<endl;
    cout << "&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&        |||%%%%%%%%%%%%%%%%%%  eeee"<<endl;
    }
    else if (charactertype == 3){
    cout << "&&&&&&&&&&&-MENU-&&&&&&&&&&&&&&                !"<<endl;
    cout << "&                             &            &&&&!!&&&&"<<endl;
    cout << "&  1. Resume Game             &           &&&&&!!&&&&&"<<endl;
    cout << "&                             &          &&&&&&!!!&&&&&"<<endl;
    cout << "&                             &         &&&&& &!!! &&&&&"<<endl;
    cout << "&  2. Save Game               &         &&&&   !!!  &&&&"<<endl;
    cout << "&                             &         &&&&& &!!! &&&&&"<<endl;
    cout << "&                             &         &&&&&&&!!!&&&&&&"<<endl;
    cout << "&  3. View Status             &          &&&&&&!!!&&&&&"<<endl;
    cout << "&                             &           &&&&&!!!&&&&"<<endl;
    cout << "&                             &        %%%%%%%%!!!%%%%%%%"<<endl;
    cout << "&  4. View Map                &       %%%%%%%%%!!!%%%%%%%%"<<endl;
    cout << "&                             &     %%%%%%%%%%%!!!%%%%%%%%%"<<endl;
    cout << "&                             &    %%%%%^%%%%%%!!!%%%%%^%%%%"<<endl;
    cout << "&  5. Go to Main Screen       &   %%%%%%^%%%%%%!!!%%%%%^%%%%%"<<endl;
    cout << "&                             &  %%%%%%%^%%%%%%!!!%%%%%^%%%%%%"<<endl;
    cout << "&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&    %%%%%%^%%%%!!!!!%%%^%%%%%%"<<endl; 
    }
    else if (charactertype == 4){
    cout << "&&&&&&&&&&&-MENU-&&&&&&&&&&&&&&                   &&&&&&&&"<<endl;
    cout << "&                             &                  &&&&&&&&&&"<<endl;
    cout << "&                             &                  &&   &   &"<<endl;
    cout << "&  1. Resume Game             &                  &&  &&&  &"<<endl;
    cout << "&                             &                  &&&&&&&&&&"<<endl;
    cout << "&                             &                  &&&&&&&&&&"<<endl;
    cout << "&  2. Save Game               &                   &&&&&&&&"<<endl;
    cout << "&                             &              %%%%%%%%%%%%%%%%%%"<<endl;
    cout << "&                             &             ^^^%%%%%%%%%%%%%%^^^"<<endl;
    cout << "&  3. View Status             &            %%^^^^%%%%,-%^^^^%^^^^"<<endl;
    cout << "&                             &            %%%^^^^%%/%%/^^^^^%^^^^"<<endl;
    cout << "&                             &            %%%%^^^^/%%///%^^^^%^^^^"<<endl;
    cout << "&  4. View Map                &            %%%%%^^^^%///%%%%^^^^^^^^"<<endl;
    cout << "&                             &            %%%%%^^^^^^/%%%%%%^^^^^^^"<<endl;
    cout << "&                             &            %%%%%/^^^^^^%%%%%%%^^^^^"<<endl;
    cout << "&  5. Go to Main Screen       &            %%%%/%%///%%%%%%%%%%%"<<endl;
    cout << "&                             &            %%%/%%///%%%%%%%%%%%%"<<endl;
    cout << "&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&              /%%///%%%%%%%%%%%%"<<endl;
    }
    
    
    
    }
    this is all below int main. the problem is that it just skips thru the function. the variable charactertype was named in the int main part. is this why it just skips it? and the reaosn why im doing this in a function is so i dont have to use the if tree muliple times and just type in void menuscren (void); even tho i thougt it would jsut be menuscreen();
    Email: Klinerr1@nc.rr.com || AIM: MisterSako || MSN: sakotheinsane@hotmail.com

    -the shroom has spoken

  2. #2
    Shadow12345
    Guest
    you need to declare menuscreen to accept an int
    Code:
    void menuscreen(int);
    This way you can create an integer in main and pass it to menuscreen when you call it.
    Code:
    int main() {
    int x = 2;
    menuscreen(2);
    return 0;
    }
    Code:
    #include <iostream>
    using namespace std;
    
    inline void menuscreen(int); //menuscreen prototype
    
    int main(void) {
    	int x = 2;
    	menuscreen(2);
    	return 0;
    }
    
    //menuscreen definition
    void menuscreen(int charactertype) {
    //menuscreen definition here
    }
    I hope that makes sense
    Last edited by Shadow12345; 07-24-2002 at 12:44 AM.

  3. #3
    Sir Mister Insane Sako Klinerr1's Avatar
    Join Date
    May 2002
    Posts
    608
    could u make that all into one thing as if it were int a compiler.... cuase it didnt caus eu split it up so much
    Email: Klinerr1@nc.rr.com || AIM: MisterSako || MSN: sakotheinsane@hotmail.com

    -the shroom has spoken

  4. #4
    Shadow12345
    Guest
    I was trying to avoid posting the entire thing but ok here you go:
    Code:
    #include <iostream>
    using namespace std;
    void menuscreen(int);
    //this is just the prototype, you do not need to put a name after
    //'int' if you don't want to
    
    
    int main(void) {
    	int x = 2;
    	menuscreen(2);
    	return 0;
    }
    
    
    void menuscreen(int charactertype)
    {
    if (charactertype == 1){
    cout << "&&&&&&&&&&&-MENU-&&&&&&&&&&&&&&                   *"<<endl;
    cout << "&                             &                    **"<<endl;
    cout << "&  1. Resume Game             &                     ****"<<endl;
    cout << "&                             &       ****          *******"<<endl;
    cout << "&                             &      *    *       *********"<<endl;
    cout << "&  2. Save Game               &      *    *     *************"<<endl;
    cout << "&                             &       ****     *****************"<<endl;
    cout << "&                             &        **        ##############"<<endl;
    cout << "&  3. View Status             &        **       ####   ##   ####"<<endl;
    cout << "&                             &        **      #####   ##   #####"<<endl;
    cout << "&                             &        **      #####   ##   #####"<<endl;
    cout << "&  4. View Map                &        **       ################"<<endl;
    cout << "&                             &        **        ##############"<<endl;
    cout << "&                             &        **         ############"<<endl;
    cout << "&  5. Go to Main Screen       &        **      %%%%%%%%%%%%%%%%%%%"<<endl;
    cout << "&                             &        **     %%%%%%%%%%%%%%%%%%%%%"<<endl;
    cout << "&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&        **   %%%%%%%%%%%%%%%%%%%%%%%%"<<endl;
    }
    else if (charactertype == 2){
    cout << "&&&&&&&&&&&-MENU-&&&&&&&&&&&&&&  <<<<<<<>>>>>>>>&&&&&&"<<endl;
    cout << "&                             & <<<<<<<<>>>>>>>>>&&&&&&"<<endl;
    cout << "&  1. Resume Game             & <<<<<<<<>>>>>>>>>&&  &&&"<<endl;
    cout << "&                             &  <<<<<<<>>>>>>>>&&&  &&&"<<endl;
    cout << "&                             &        |||   &&&&&&&&&&&"<<endl;
    cout << "&  2. Save Game               &        |||   &&&&&&&&&&&"<<endl;
    cout << "&                             &      %%|||%%  &&&&&&&&&   %%%%%"<<endl;
    cout << "&                             &      eeeeeee%%%%%%%%%%%%%%%%%%%%%"<<endl;
    cout << "&  3. View Status             &      eeeeeee%%%%%%%%%%%%%%%%%%%%%"<<endl;
    cout << "&                             &      eeeeeee%%%%%%%%%%%%%%%%%%%%e"<<endl;
    cout << "&                             &        |||%%%%%%%%%%%%%%%%%%%%eee"<<endl;
    cout << "&  4. View Map                &        |||%%%%%%%%%%%%%%%%%%%eeeee"<<endl;
    cout << "&                             &        |||%%%%%%%%%%%%%%%%%%eeeeeee"<<endl;
    cout << "&                             &        |||%%%%%%%%%%%%%%%%%%eeeeeee"<<endl;
    cout << "&  5. Go to Main Screen       &        |||%%%%%%%%%%%%%%%%%%%eeeeee"<<endl;
    cout << "&                             &        |||%%%%%%%%%%%%%%%%%%% eeee"<<endl;
    cout << "&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&        |||%%%%%%%%%%%%%%%%%%  eeee"<<endl;
    }
    else if (charactertype == 3){
    cout << "&&&&&&&&&&&-MENU-&&&&&&&&&&&&&&                !"<<endl;
    cout << "&                             &            &&&&!!&&&&"<<endl;
    cout << "&  1. Resume Game             &           &&&&&!!&&&&&"<<endl;
    cout << "&                             &          &&&&&&!!!&&&&&"<<endl;
    cout << "&                             &         &&&&& &!!! &&&&&"<<endl;
    cout << "&  2. Save Game               &         &&&&   !!!  &&&&"<<endl;
    cout << "&                             &         &&&&& &!!! &&&&&"<<endl;
    cout << "&                             &         &&&&&&&!!!&&&&&&"<<endl;
    cout << "&  3. View Status             &          &&&&&&!!!&&&&&"<<endl;
    cout << "&                             &           &&&&&!!!&&&&"<<endl;
    cout << "&                             &        %%%%%%%%!!!%%%%%%%"<<endl;
    cout << "&  4. View Map                &       %%%%%%%%%!!!%%%%%%%%"<<endl;
    cout << "&                             &     %%%%%%%%%%%!!!%%%%%%%%%"<<endl;
    cout << "&                             &    %%%%%^%%%%%%!!!%%%%%^%%%%"<<endl;
    cout << "&  5. Go to Main Screen       &   %%%%%%^%%%%%%!!!%%%%%^%%%%%"<<endl;
    cout << "&                             &  %%%%%%%^%%%%%%!!!%%%%%^%%%%%%"<<endl;
    cout << "&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&    %%%%%%^%%%%!!!!!%%%^%%%%%%"<<endl; 
    }
    else if (charactertype == 4){
    cout << "&&&&&&&&&&&-MENU-&&&&&&&&&&&&&&                   &&&&&&&&"<<endl;
    cout << "&                             &                  &&&&&&&&&&"<<endl;
    cout << "&                             &                  &&   &   &"<<endl;
    cout << "&  1. Resume Game             &                  &&  &&&  &"<<endl;
    cout << "&                             &                  &&&&&&&&&&"<<endl;
    cout << "&                             &                  &&&&&&&&&&"<<endl;
    cout << "&  2. Save Game               &                   &&&&&&&&"<<endl;
    cout << "&                             &              %%%%%%%%%%%%%%%%%%"<<endl;
    cout << "&                             &             ^^^%%%%%%%%%%%%%%^^^"<<endl;
    cout << "&  3. View Status             &            %%^^^^%%%%,-%^^^^%^^^^"<<endl;
    cout << "&                             &            %%%^^^^%%/%%/^^^^^%^^^^"<<endl;
    cout << "&                             &            %%%%^^^^/%%///%^^^^%^^^^"<<endl;
    cout << "&  4. View Map                &            %%%%%^^^^%///%%%%^^^^^^^^"<<endl;
    cout << "&                             &            %%%%%^^^^^^/%%%%%%^^^^^^^"<<endl;
    cout << "&                             &            %%%%%/^^^^^^%%%%%%%^^^^^"<<endl;
    cout << "&  5. Go to Main Screen       &            %%%%/%%///%%%%%%%%%%%"<<endl;
    cout << "&                             &            %%%/%%///%%%%%%%%%%%%"<<endl;
    cout << "&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&              /%%///%%%%%%%%%%%%"<<endl;
    }
    
    
    
    }
    Hope that helps

  5. #5
    Sir Mister Insane Sako Klinerr1's Avatar
    Join Date
    May 2002
    Posts
    608
    god bless you, you are da bomb, ive been working on this for like a week.
    Email: Klinerr1@nc.rr.com || AIM: MisterSako || MSN: sakotheinsane@hotmail.com

    -the shroom has spoken

  6. #6
    x4000 Ruski's Avatar
    Join Date
    Jun 2002
    Location
    Outer Space!
    Posts
    542
    Nice drawing Did you draw that alone?
    what does signature stand for?

  7. #7
    Sir Mister Insane Sako Klinerr1's Avatar
    Join Date
    May 2002
    Posts
    608
    my freind (civex) drew the mage i drew the others
    Email: Klinerr1@nc.rr.com || AIM: MisterSako || MSN: sakotheinsane@hotmail.com

    -the shroom has spoken

Popular pages Recent additions subscribe to a feed

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