Feb 16, 2015 at 7:39am UTC
Just started with C++, no programming experience apart from working with mSL.
My idea is to have user input select a file which will read the questions in their preferred language. But I can't use "File = "File.txt";" on an int, what should I use?
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
//Assignment 1 by Nillen
#include <iostream>
#include <fstream>
using namespace std;
int main()
{ //Main opening bracket
int tries, highest, lowest, file; //Create the variables
lowest = 1; //Starting value of lowest guess
highest = 100; //Starting value of max guess
tries = 0; //To increase once per turn
cout << "Which language do you prefer? \nVilket språk föredrar du? \nどのような言語あなたが好きですか\n" ;
cout << "1: English\n" ;
cout << "2: Svenska\n" ;
cout << "3: 日本語\n" ;
while (true )
{ //Infinite while opening bracket
char LangPref; //User's choice
cin >> LangPref;
if (LangPref == 1)
{
file = "english.txt" ;
break ;
}
else if (LangPref == 2)
{
file = "swedish.txt" ;
break ;
}
else if (LangPref == 3)
{
file = "japanese.txt" ;
break ;
}
else
{
cout << "Error: " << LangPref << "is not valid." ;
}
} //Infinite while closing bracket
cin.get();
return 0;
} //Main closing bracket
I'm well aware that letters like åäö can't be written like that, I'll fix it later.
Last edited on Feb 16, 2015 at 7:44am UTC