I'm a very beginner programmer and I'm trying to create a multiple languages application in c++, am also using functions, I'd appreciate if anyone could show some guidance as I can't seem to figure out how to properly return the value language, to later add a loop, the loop part I know how to. Thank you in advance
[#include <iostream>
usingnamespace std;
//choice between english and another language
int getLanguage();
//function to welcome the user
void displayWelcomeMessage(int);
//main menu choices
int main()
{
int language = 0;
language = getLanguage();
displayWelcomeMessage(language);
system("PAUSE");
return 0;
}
int getLanguage()
{
int language = 2;
/*while (lang < 1 || lang > 2)
{
cout << "Choose a language from bellow:\n";
cout << "1- English \n2- Español\n";
cin >> lang;
count++;
if (count == 5)
lang = 1;
}*/
return language;
}
void displayWelcomeMessage(int language)
{
if (language = 1)
{
cout << "\\*\\*\\*\\*\\ Welcome to The Space ";
cout << "Travel Online Center! /*/*/*/*/" << endl;
}
elseif (language = 2)
{
cout << "\\*\\*\\*\\*\\ Bienvenido al Centro Online de ";
cout << " Viaje Espacial! /*/*/*/*/" << endl;
}
}
]
Put the code you need help with here.
[/int getLanguage()
{
int language = 2;
return language;
}]
Line 42,47: You're using the assignment operator (=), not the comparison operator (==).
24 25 26 27 28 29 30 31 32 33 34 35 36 37
int getLanguage()
{ int count = 0; // was not defined
int lang = 0; // initialize to a value that forces you through the loop
while (lang < 1 || lang > 2)
{ cout << "Choose a language from bellow:\n";
cout << "1- English \n2- Español\n";
cin >> lang;
count++;
if (count == 5)
lang = 1;
}
return lang; // return lang, not language
}
PLEASE ALWAYS USE CODE TAGS (the <> formatting button) when posting code.
It makes it easier to read your code and also easier to respond to your post. http://www.cplusplus.com/articles/jEywvCM9/
Hint: You can edit your post, highlight your code and press the <> formatting button.