So, I have this array of structs and a file in which I need to copy all information to the struct, can I do something like this? If not how could I do this?
#include <stdio.h>
#include <iostream>
using namespace std;
typedef struct{
int x;
int y;
int z;
}coordinates;
int main(){
coordinates coordinate[100];
int i = 0;
FILE *f;
f = fopen("file.file","rb");
if(!f){
cout << "Error";
return 0;
}
while(!feof(f)){
fread(coordinate[i],sizeof(coordinates),1,f);
i++;
}
return 0;
}