So the problem is foo function where I should take person atributes do some changes with them and rewrite them to another file but fprintf function have some problem with p_person->name if anybody can help me, I would be very thankfull
its all written in main I just made it smaller...
Code:
struct person {
char* name;
} person;
FILE * pFile;
char * buffer;
char * line;
pFile = fopen ("data.dat","r");
fgets(buffer,100,pFile);
line = malloc (strlen(buffer)+1 * sizeof(char));
strcpy(line,buffer);
char* pointer=strchr(line,':');
*(pointer)='\0';
char* person_name = malloc (strlen(line)+1 * sizeof(char));
strcpy(person_name,line);
struct person* pMyPerson = malloc(sizeof(struct person));
pMyPerson->name = malloc (strlen(person_name)+1 * sizeof(char));
strcpy(pMyPerson->name,person_name);
fclose (pFile);
printf("%s",pMyPerson->name);
void foo(struct person* p_person){
FILE * output= fopen("datat.txt","w");
fprinf(output, "%s", (p_person)->name);
fclose (output);
}
foo(pMyPerson);
free(line);