Guest User

Untitled

a guest
Jan 17th, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.51 KB | None | 0 0
  1. typedef struct {
  2.  
  3. char *first_name;
  4. char *last_name;
  5.  
  6. } contact;
  7.  
  8. void print_contact(contact *c) {
  9. printf("Name: %s %sn", c->first_name, c->last_name);
  10. }
  11.  
  12. contact *populate_contact() {
  13.  
  14. contact *c;
  15. char *input;
  16.  
  17. c = (contact *)malloc(sizeof(contact));
  18.  
  19. printf(">>> Please Input The First Name: ");
  20. fgets(input, 100, stdin);
  21. c->first_name = strdup(input);
  22. c->last_name = "Doe";
  23.  
  24. }
  25.  
  26.  
  27. int main() {
  28.  
  29.  
  30. contact m = *populate_contact();
  31.  
  32. print_contact(&m);
  33.  
  34.  
  35. return 0;
  36. }
Add Comment
Please, Sign In to add comment