#ifndef PERSON_H

Please, what is wrong here? I wrote iet literarily from one book down...
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
  #ifndef PERSON_H
#define PERSON_H

enum gender {male, female};

struct date
{int day;
int month;
int year;
}
struct person
{
char name[20];
gender genderp;
char adress[30];
date birthdate;
};
#endif//PERSON_H

#include<iostream>
#include"person.h"
using namespace std,
int main()
{

person friend= {"Mark", male, "New York Street 47", {23, 7, 1979}}
}}
cout<<"Name: "<<friend.name<<endl;
cout<<"Spol: "<<friend.generp==male)?"male":"female")<<endl;
cout<<"Adress: "<<friend.adress<<endl;
cout<<"Birthday: "<<friend.birthdate.day<<"."<<friend.birthdate.month<<"."<<friend.birthdate.year<<"."<<endl;
return o;
}
 




1
2
3
4
5
6
7
Line 18: error: person.h: No such file or directory
Line 21: error: multiple types in one declaration
compilation terminated due to -Wfatal-errors.
 
 

Last edited on
6
7
8
9
10
struct date
{int day;
int month;
int year;
} // <-- missing semicolon 


20
21
22
23
#include<iostream>
#include"person.h"
using namespace std, // <-- should be semicolon, not comma
int main()


26
27
person friend= {"Mark", male, "New York Street 47", {23, 7, 1979}}
}} // <-- what's up with these braces? Also, no semicolon at the end 

Also, friend is a special keyword in C++, so you're going to have to name it something different.

28
29
cout<<"Name: "<<friend.name<<endl;
cout<<"Spol: "<<friend.generp==male)?"male":"female")<<endl;

genderp is misspelled here, and your parenthesis don't match up and don't seem to be in the right place.

32
33
return o; // <-- 0, not o
}
Many thanks!
(Really woudld newer say for : friend!:d!)

What is wrong NOW?

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
#ifndef PERSON_H
#define PERSON_H

enum gender {male, female};

struct date
{int day;
int month;
int year;
};
struct person
{
char name[20];
gender genderp;
char adress[30];
date birthdate;
};
#endif//PERSON_H

#include<iostream>
#include"person.h"
using namespace std;
int main()
{

person ffriend= {"Mark", male, "New York Street 47", {23, 7, 1979}};

cout<<"Name: "<<ffriend.name<<endl;
cout<<"Gender: "<<((ffriend.genderp==male)?"male":"female")<<endl;
cout<<"Adress: "<<ffriend.adress<<endl;
cout<<"Birthday: "<<ffriend.birthdate.day<<"."<<ffriend.birthdate.month<<"."<<ffriend.birthdate.year<<"."<<endl;
return 0;
}



Line 18: error: person.h: No such file or directory
Last edited on
it says it cannot find a file named "person.h"

the author meant that you should put :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#ifndef PERSON_H
#define PERSON_H

enum gender {male, female};

struct date
{int day;
int month;
int year;
};
struct person
{
char name[20];
gender genderp;
char adress[30];
date birthdate;
};
#endif//PERSON_H 


into another file named "person.h"
You will need to make a new file called "person.h" and copy paste those contents into it. I usually put my own header files into the project's own folder.
If you then go to compile your project and get an error about not finding person.h, you need to go and tell the compiler where to search for that header file. Depending on what IDE (or other thing) you're using, doing this will have a different exact answer.

Your code would benefit from proper indentation. It might not seem important now, but when your files become bigger, it's much easier for you and others to find errors if the code is properly indented.

You might also want to fix the error 'adress' in your code. Correct spelling is 'address'. Misspellings like that can cause problems in future.
Topic archived. No new replies allowed.