Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- int main()
- {
- typedef struct employee
- {
- char first_name[16];
- char last_name[16];
- float salary;
- struct employee *next_record;
- } employee;
- employee *jane = malloc(sizeof(employee));
- employee *john = malloc(sizeof(employee));
- strcpy(jane->first_name, "Jane");
- strcpy(jane->last_name, "Doe");
- jane->salary = 1234;
- jane->next_record = john;
- strcpy(john->first_name, "John");
- strcpy(john->last_name, "Doe");
- john->salary = 2345;
- john->next_record = NULL;
- employee *current = jane;
- do
- {
- printf("First name: %s\n", current->first_name);
- printf("Last name: %s\n", current->last_name);
- printf("Salary: %.4f\n", current->salary);
- putchar('\n');
- current = current->next_record;
- }
- while(current != NULL);
- }
- /* First name: Jane
- * Last name: Doe
- * Salary: 1234.0000 */
- /* First name: John
- * Last name: Doe
- * Salary: 2345.0000 */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement