Getting the following warning message:
database.c:15:19: warning: assignment makes integer from pointer without a cast [-Wint-conversion]
ptr->LastName[0] = NULL;
^
database.c:16:26: warning: assignment makes integer from pointer without a cast [-Wint-conversion]
ptr->FirstMiddleName[0] = NULL;
^
I tried using pointers a few different ways but I don't understand them very well and can't figure out how to avoid this.
#include <stdio.h>
int main() {
struct employee {
char LastName[30];
char FirstMiddleName[35];
float Salary;
int YearHired;
};
struct employee employees[20];
struct employee *ptr, person;
ptr = &person;
ptr->LastName[0] = NULL;
ptr->FirstMiddleName[0] = NULL;
ptr->Salary = -1;
ptr->YearHired = -1;
printf("%i", person.YearHired);
printf("%s", person.LastName[0]);
for(int i = 0; i < 20; i++) {
employees[i] = person;
//printf("%i\n", i);
}
printf("%c", employees[3].LastName[0]);
}
I would like to initialize an array of 20 "employees" with the initial values such that numerical values are set to -1, and the strings contain the null character as the zeroth character. Instead I get the above warning, and if I replace the NULL assignment with a letter it says "Segmentation fault (core dumped)".