Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
C++ Madness: File I/O with "char"
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Portage & Programming
View previous topic :: View next topic  
Author Message
wswartzendruber
Veteran
Veteran


Joined: 23 Mar 2004
Posts: 1261
Location: Idaho, USA

PostPosted: Mon Sep 01, 2014 10:50 pm    Post subject: C++ Madness: File I/O with "char" Reply with quote

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
View user's profile Send private message
Hu
Moderator
Moderator


Joined: 06 Mar 2007
Posts: 21607

PostPosted: Tue Sep 02, 2014 12:39 am    Post subject: Reply with quote

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
View user's profile Send private message
046
Apprentice
Apprentice


Joined: 21 Jul 2004
Posts: 231
Location: Yaroslavl, Russia

PostPosted: Tue Sep 02, 2014 11:52 am    Post subject: Re: C++ Madness: File I/O with "char" Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Portage & Programming All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum