Help a fellow programmer

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

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
[#include <iostream>

using namespace 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;
	}
	else if (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;
}]
Last edited on
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.
Last edited on
Topic archived. No new replies allowed.