Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- typedef struct
- {
- char firstName[10];
- char lastName[10];
- char gender[10];
- char age[2];
- char eyeColor[10];
- } Person; // create a person struct
- size_t stringlen(const char *); // function prototype of stringlen
- char * stringcpy(char *, const char *); // function prototype of stringcpy
- char * stringcat(char *, const char *); // function prototype of stringcat
- int isEqual(const Person*, const Person*); // function prorotype for isEqual
- int main()
- {
- Person person1;
- Person person2;
- printf("Enter first name: ");
- fgets(person1.firstName, 20, stdin);
- printf("Enter last name: ");
- fgets(person1.lastName, 20, stdin);
- printf("Enter gender: ");
- fgets(person1.gender, 10, stdin);
- printf("Enter age: ");
- fgets(person1.age, 2, stdin);
- printf("Enter eye color: ");
- fgets(person1.eyeColor, 10, stdin);
- if (isEqual(&person1, &person2)) {
- printf("Person 1 and Person 2 are equal\n");
- } else {
- printf("Person 1 and Person 2 are not equal\n");
- }
- }
- Output
- Enter first name: Tori
- Enter last name: Torii
- Enter gender: Female
- Enter age: 20
- Enter eye color: Person 1 and Person 2 are equal
- Press any key to continue . . .
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement