Sign in to follow this  
evervoid

C++ Problem

Recommended Posts

evervoid    122
hey, i'm just starting to use C++ and i'm trying to get this code to work, it compiles but for some reason the second function doesn't work, heres the code:
 #include <cstdlib>
#include <iostream>
#include <string>

using namespace std;

string input;
string output;

int b;

int options()
{
    int b;
    
     cout << "1. DFO\n";
     cout << "2. WoW\n";
     cout << "3. WC3\n\n";
     cin >> b;
     
     return(b);
}

string func(int a)
{      
     if(a == 1)
     {
         string output = "DFO";
     } else if ( a == 2) {
            
            output = "WoW";
     } else if (a == 3)  {
            
            output = "WC3";
     }
     return (output);
}

int main()
{
    int choice;
    string out;

    choice = options();
    cout << func(choice);
    cin >> out;
}
    


any ideas?

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this