Advertisement
Guest User

Untitled

a guest
Aug 20th, 2018
240
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4.  
  5. struct User
  6. {
  7. char* username;
  8. char* password;
  9. };
  10.  
  11. void initialize_users(struct User* user, int index)
  12. {
  13. user[index].username = (char*)malloc(sizeof(char) * 32);
  14. user[index].password = (char*)malloc(sizeof(char) * 32);
  15. }
  16.  
  17. void free_users(struct User* user, int index)
  18. {
  19. free(user[index].username);
  20. free(user[index].password);
  21. }
  22. int main( void )
  23. {
  24. struct User users[10];
  25. initialize_users(users,0);
  26. printf("Please enter something \n");
  27. scanf("%s", users[0].username);
  28. printf("%s\n", users[0].username);
  29.  
  30. free_users(users,0);
  31. return 0;
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement