Last two questions then I think the program is finished.
1) The program skip the first question and jump directly to the second. Why? And how do you fix it?
2) The program crash now when it comes to last question. If you lower n to a lower number then it won´t crash.
Thanks for all the help I got earlier and now!
Code:
#include <string>
#include <iostream>
using namespace std;
int main()
{
cout << "Welcome to program Planets! \n";
cout << "Valj mellan" << "\n";
cout << "1: Svenska" << "\n";
cout << "2: English" << "\n";
string val;
cin >> val;
if (val == "1")
{
//char startfraga[] = "Vad heter den ";
char fraga1[] = "Merkurius";
char fraga2[] = "Venus";
char fraga3[] = "Tellus";
char fraga4[] = "Mars";
char fraga5[] = "Jupiter";
char fraga6[] = "Saturnus";
char fraga7[] = "Uranus";
char fraga8[] = "Neptunus";
unsigned short int x;
x = 0;
char *fraga[] = { fraga1, fraga2, fraga3, fraga4, fraga5, fraga6, fraga7, fraga8 };
string svar[8];
for (int n = 1; n <= 8; ++n)
{
cout << "Vad heter " << n << " planeten? ";
cin >> svar[n];
}
cout << "You have entered: ";
for (int n = 1; n <= 8; ++n)
{
cout << svar[n] << ", ";
if (svar[n] == fraga[n])
{x++;}
else if (svar[n] != fraga[n])
{x;}
}
cout << "\n Grattis ni fick " << x << " ratt" << "\n" << "\n" << "\n";
cout << "Foljande var fel:";
for (int n = 1; n <= 8; ++n)
{
if (svar[n] != fraga[n])
{cout << svar[n] << ", ";}
}
int asd;
cout << "";
cin >> asd;
}
}