View previous topic :: View next topic |
Author |
Message |
wswartzendruber Veteran
Joined: 23 Mar 2004 Posts: 1261 Location: Idaho, USA
|
Posted: Mon Sep 01, 2014 10:50 pm Post subject: C++ Madness: File I/O with "char" |
|
|
libogg is giving me "unsigned char*" buffers that I need to send to an ofstream.
PROBLEM: <ofstream> takes char*, not unsigned char*.
Can I just use reinterpret_cast<char*> on these things? That seems like a really, really bad idea.
EDIT: How the hell does a signed char map to the extended ASCII table, anyway?
EDIT: Who the fuck thought of this?! |
|
Back to top |
|
|
Hu Moderator
Joined: 06 Mar 2007 Posts: 21607
|
Posted: Tue Sep 02, 2014 12:39 am Post subject: |
|
|
Why are you sending it to an ofstream? You probably want to write the data through unmodified, so use write. File streams take char* because they are mostly used with printable text and historically, printable text was char* and more recently const char*. |
|
Back to top |
|
|
046 Apprentice
Joined: 21 Jul 2004 Posts: 231 Location: Yaroslavl, Russia
|
Posted: Tue Sep 02, 2014 11:52 am Post subject: Re: C++ Madness: File I/O with "char" |
|
|
wswartzendruber wrote: | libogg is giving me "unsigned char*" buffers that I need to send to an ofstream.
PROBLEM: <ofstream> takes char*, not unsigned char*.
Can I just use reinterpret_cast<char*> on these things? That seems like a really, really bad idea. |
Use cast, it is ok really. |
|
Back to top |
|
|
|