mardi 21 février 2017

What's the difference between cast to char* and cast to const char*?

I'm reading some codes where sometimes casting integer reference value to const char * used with ostream is happened.

uint32_t val;// initialized by some value
void a(ostream& os) const{
     os.write((const char*)&val, sizeof(val));
}

Is it same to use (char *)&val as to use (const char *)?? If not, what's the difference??

Aucun commentaire:

Enregistrer un commentaire