typedef struct person {
int id;
char* name;
} Person;
//constructor like function
Person* New_Person(int id,char *name){
Person* p = malloc(sizeof(Person));
p->id = id;
p->name = name;
//return p;
}
int main(){
for(int i=0;i<10;i++){
Person* p = New_Person(i,"abcd");
printf("id:%d name:%s \n",p->id,p->name);
}
printf("DONE\n");
return 0;
}
New_Person
is like a constructor and its supposed to return a pointer to the newly allocated person, if i comment the return statement in the New_Person
function i still get the same behavior, can someone please explain to me why it compiles and gives the same behavior without a return statement?