I'm also a total beginner, but:
Further to what Yanson said: if you use std::string, you'll need to change
#include <cstring>
to
#include <string>
When he says you didn't put anything for Greece or Birmingham, he means you declared a variable, but didn't give it any value (either at the moment of initializing or later). You then call that non-existent variable in a function, which won't work.
Or to put it another way, this is ok:
1 2 3 4 5 6 7 8 9 10
|
#include "stdafx.h"
#include <iostream>
#include <string>
int main()
{
std::string hello;
hello = "Hello";
std::cout << hello << "\n";
}
|
But this is not ok (or at least, it's a program that does nothing):
1 2 3 4 5 6 7 8 9
|
#include "stdafx.h"
#include <iostream>
#include <string>
int main()
{
std::string hello;
std::cout << hello << "\n";
}
|
Here's your program re-written using std::string. As you can see, i've removed the greece and birmingham chars (or strings) in lines 10 & 11, they're not necessary!
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
|
#include <iostream>
#include <string>
using namespace std;
int main()
{
std::string aa;
std::string bb;
cout << "what destination are you travelling? \n";
cin >> aa;
cout << "where will you be flying from? \n";
cin >> bb;
if ((aa == "greece") && (bb == "birmingham")) {
cout << "ahh usual summer holiday? \n";
}
if ((aa != "greece") && (bb != "birmingham")) {
cout << "where are you flying from then? \n";
}
return 0;
}
|