I have to complete this exercise: I have to read from a generic text file, thus composed: [Nameperson][space][age],and i have to save the name(char) and the age(unsigned int) in a struct.
My problem is: I don't understand how to divide the name and age, that is, if I use a fread_s, in this way
fread_s(pp->name, 256, 1, 256, f);
the program saves me as name es.
Pippo 25iiiiiiiiiiiiiiiiiiiiiiiiii...
I know that the fread_s function maintain the position of the last letter read, but I do not know how to use this to my advantage . This is my code
#include <stdio.h>
#include <string.h>
struct person{
char name[256];
unsigned int age;
};
void person_read(FILE *f, struct person* pp) {
fread_s(pp->name, 256, 1, 256, f);
}
Thanks.