Hello this is my first time posting on this site and also I am not very familiar with structures or with strcpy()
I was wondering why my program below is crashing.
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <string.h>
struct Employee{
char name[30];
char email[30];
};
void main(){
struct Employee x;
char employee_name[30];
char employee_email[30];
printf("enter the employees's name\n");
fgets(employee_name,30,stdin);
strcpy(x.name, employee_name);
printf("enter the employee's email\n");
fgets(employee_email,30,stdin);
strcpy(x.email,employee_email);
printf('%s',x.name);
printf('%s',x.email);
}
The purpose of the program is basically to accept a name and email as input and put it in the name and email of the structure and than print them using the structure. Now the program compiles and allows me to take the input but after that it crashes and I do not know why. Does anyone know why the crash is occurring?