Advertisement
Guest User

Untitled

a guest
Feb 19th, 2017
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.15 KB | None | 0 0
  1. typedef struct
  2. {
  3.     char firstName[10];
  4.     char lastName[10];
  5.     char gender[10];
  6.     char age[2];
  7.     char eyeColor[10];
  8. } Person; // create a person struct
  9.  
  10. size_t stringlen(const char *); // function prototype of stringlen
  11. char * stringcpy(char *, const char *); // function prototype of stringcpy
  12. char * stringcat(char *, const char *); // function prototype of stringcat
  13. int isEqual(const Person*, const Person*); // function prorotype for isEqual
  14.  
  15. int main()
  16. {
  17.     Person person1;
  18.     Person person2;
  19.     printf("Enter first name: ");
  20.     fgets(person1.firstName, 20, stdin);
  21.  
  22.     printf("Enter last name: ");
  23.     fgets(person1.lastName, 20, stdin);
  24.  
  25.     printf("Enter gender: ");
  26.     fgets(person1.gender, 10, stdin);
  27.  
  28.     printf("Enter age: ");
  29.     fgets(person1.age, 2, stdin);
  30.  
  31.     printf("Enter eye color: ");
  32.     fgets(person1.eyeColor, 10, stdin);
  33.  
  34.     if (isEqual(&person1, &person2)) {
  35.         printf("Person 1 and Person 2 are equal\n");
  36.     } else {
  37.         printf("Person 1 and Person 2 are not equal\n");
  38.     }
  39. }
  40.  
  41. Output
  42. Enter first name: Tori
  43. Enter last name: Torii
  44. Enter gender: Female
  45. Enter age: 20
  46. Enter eye color: Person 1 and Person 2 are equal
  47. Press any key to continue . . .
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement