Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- struct Employee{
- char firstName[256];
- char lastName[256];
- int age;
- int sinNumber;
- char status;
- };
- struct Node{
- struct Employee employee;
- struct Node *next;
- };
- int addEmployee(struct node** _head, struct node* toAdd){
- if (*_head == NULL){
- _head = toAdd;
- _head->next = NULL;
- }
- else{
- toAdd->next = _head;
- head = toAdd;
- }
- }
- void displayEmployees(struct node* _employees){
- for(struct node* current = _employees;current!=NULL;current=current->next){
- printf("%s, %s\n%d\n%d\n%c\n", current->employee.lastName, current->employee.firstName, current->employee.age, current->employee.sinNumber, current->employee.status);
- }
- }
- int main(){
- char firstName[256] = "Cody";
- char lastName[256] = "Scott";
- int age = 19;
- int sinNumber = 123;
- char status = 'a';
- struct node* employees;
- employees = (struct node*) malloc (sizeof(struct node));
- employees = NULL;
- struct node* employee;
- employee = (struct node*) malloc (sizeof(struct node));
- strcpy(employee->firstName, firstName);
- strcpy(employee->lastName, lastName);
- employee->age = age;
- employee->sinNumber = sinNumber;
- strcpy(employee->status, status);
- addEmployee(&employees, employee);
- displayEmployees(employees);
- return 0;
- }
Add Comment
Please, Sign In to add comment