#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;
}
C++ Problem
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:
any ideas?
The only part of the second function that won't work is when a == 1. Declare output at the start of the function instead of in the "if" statement.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement