Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- struct User
- {
- char* username;
- char* password;
- };
- void initialize_users(struct User* user, int index)
- {
- user[index].username = (char*)malloc(sizeof(char) * 32);
- user[index].password = (char*)malloc(sizeof(char) * 32);
- }
- void free_users(struct User* user, int index)
- {
- free(user[index].username);
- free(user[index].password);
- }
- int main( void )
- {
- struct User users[10];
- initialize_users(users,0);
- printf("Please enter something \n");
- scanf("%s", users[0].username);
- printf("%s\n", users[0].username);
- free_users(users,0);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement