Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int deserialize_students(const Student *dest, const int destCapacityMax)
- {
- FILE *ptr_file;
- int i=0;
- ptr_file =fopen("output.txt","r");
- if (!ptr_file)
- return -1;
- if(destCapacityMax==0)
- return -2;
- while (!feof (ptr_file))
- {
- fscanf (ptr_file, "%d", &dest[i].id); // UB?
- fscanf (ptr_file, "%s", dest[i].name);
- fscanf (ptr_file, "%d", &dest[i].gender);
- i++;
- if(i==destCapacityMax)
- return 0;
- }
- fclose(ptr_file);
- return 0;
- }
- Student students[5];
- deserialize_students(students,5);
- int func(const int *p) {
- int *q = (int*)p;
- *q = 5;
- }
- int func(const int *p) {
- fscanf(stdin, "%d", p);
- }
- warning: writing into constant object (argument 3) [-Wformat=]
- int id;
- fscanf (ptr_file, "%d", &id);
- dest[i].id = id; // here you get an error
Add Comment
Please, Sign In to add comment