Jump to content

  • Log In with Google      Sign In   
  • Create Account

Banner advertising on our site currently available from just $5!


1. Learn about the promo. 2. Sign up for GDNet+. 3. Set up your advert!


#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