vendredi 26 février 2016

Streaming file to struct

struct S {
char[10] bytes;
uint64_t t;
};


ifstream& operator>>(ifstream& ref, S& s){
  ref >> s.bytes;
  ref >> s.t;
return ref;
}
int main(){
S s;
ifstream file(/*OPEN STH*/);
file >> s;
};

The above code causes SIGESV error.

The below code doesn't causes SIGESV:

 struct S {
    char bytes; // only difference
    uint64_t t;
    };
     // .... (the same as above)

So we can see that the problem is when member bytes is an array of char. Why? How to solve that issue?

Aucun commentaire:

Enregistrer un commentaire