Family age database c++

I'm trying to create a small program where the user can input one of the strings name and he will receive teh value. In this case you put the name of a person from ym family and his age will pop up. I've written all the code i jsut don't know what's wrong with it. Can anybody help me fixing it. Plz post the correct code if you can. Thanks.

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
#include <iostream>
#include <string>
using namespace std;

int main()
{
string father = "Vinicius", mother = "Sonia", sister = "Ana", brother="Ruben";
int fatherAge = 38, motherAge = 36, sisterAge = 17, brotherAge = 13;
string name;
int age=0;
cout << "Hi! this is roberto's family age database.";
{
cin >> name;
}
if ( strcmp(father, name)==0 ){ 
cout << fatherAge;
}
else if ( strcmp(mother, name)==0 ){ 
cout << motherAge;
}
else if ( strcmp(sister, name)==0 ){ 
cout << sisterAge;
}
else if ( strcmp(brother, name)==0 ) {
cout<<brotherAge;
}
else cout<<"Invalid Name";
system("pause");
return 0;
}
would've been nice if you'd told us what error you encountered, write that down. Anyway, when comparing strings use the == operator, not strcmp, this is c++ not c
i got an error on if ( strcmp(father, name)==0 ){
can you post the correct way i should type it?
quirky thank you so much. i shoudl have typed if (father == name) cout << fatherage;
else cout << "Invalid Name";
Seriously thank you so much. I've been trying to ifx this since yesterday. HOUrs on end. Thank you tHANK YOU!
if ( father == name ) {

also, when posting code put it in code tags like above by writing
[code]
before your code and
[/code]
after your code
Topic archived. No new replies allowed.