I'm currently working on a c project, and I keep getting the same error when I try and run the program. There's a total of 3 files in the program, a main.c, a header.c and a header.h. Here is the complete code of the filest:
main.c
#include "header.h"
#include <stdio.h>
int main() {
printf("Hello");
Person p1;
p1.age = 15;
p1.name = "bob";
printPerson(p1);
}
header.h
#ifndef HEADER_H
#define HEADER_H
typedef struct person_t {
char* name;
int age;
} Person;
void printPerson (Person person);
#endif
header.c
#include <stdio.h>
#include "header.h"
void printPerson (Person person) {
printf("Name: %s, age: %d", person.name, person.age);
}
I used the "run" button in this specific example, but even when I used gcc the .exe file just got stuck when arriving at the problematic function. It looks like I'm missing something important but I can't tell what it is... any ideas?