Jump to content

  • Log In with Google      Sign In   
  • Create Account

Interested in a FREE copy of HTML5 game maker Construct 2?

We'll be giving away three Personal Edition licences in next Tuesday's GDNet Direct email newsletter!

Sign up from the right-hand sidebar on our homepage and read Tuesday's newsletter for details!


We're also offering banner ads on our site from just $5! 1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


#ActualÁlvaro

Posted 31 July 2013 - 08:08 AM

EDIT: Nevermind


#2Álvaro

Posted 31 July 2013 - 08:07 AM

u8 readU8(istream& file)
{
  u8 value = '\0';
  file.read((char*)value,1);
  return value;
}

 

That is just wrong. You want to pass a pointer to the character, and that's not what a cast to `char *' does: You need to take the address of the character using `&'. Also, you don't need to initialize `value', so don't.

 

EDIT: Of course, the same applies to the code to write.


#1Álvaro

Posted 31 July 2013 - 08:06 AM

u8 readU8(istream& file)
{
  u8 value = '\0';
  file.read((char*)value,1);
  return value;
}

 

That is just wrong. You want to pass a pointer to the character, and that's not what a cast to `char *' does: You need to take the address of the character using `&'. Also, you don't need to initialize `value', so don't.


PARTNERS