29 lines
563 B
C
29 lines
563 B
C
#include "teacher.h"
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
|
|
struct Teacher{
|
|
char name[50];
|
|
int age;
|
|
enum Level l;
|
|
long salary;
|
|
};
|
|
|
|
struct Teacher* new_teacher(char* name, int age, enum Level l) {
|
|
struct Teacher* t = (struct Teacher*) malloc(sizeof(struct Teacher));
|
|
if(t == NULL) return NULL;
|
|
//*tmp = struct Teacher {name, age, l, 0};
|
|
|
|
strncpy(t->name, name, 49);
|
|
t->name[49] = '\0';
|
|
t->age = age;
|
|
t->l = l;
|
|
t->salary = 0;
|
|
|
|
return t;
|
|
}
|
|
|
|
void add_salary(struct Teacher* t, long s) {
|
|
t->salary += s;
|
|
}
|