byte

C

Christopher

Why do so many C APIs buffer bytes using a char * param instead of an
unsigned char * param?

I am finding an aweful lot of people have mistaken the param to mean
"pass me a string" when the real intent was "pass me raw bytes"

The signed-ed-ness really doesn't matter I suppose as there is some
kind of transformation on the way in and on the way out (if the author
had a clue what they were doing), but I do wonder why signed was
chosen rather than unsigned, so often?
 
J

Juha Nieminen

Christopher said:
Why do so many C APIs buffer bytes using a char * param instead of an
unsigned char * param?

The C standard functions tend to use void* instead.

In C++ std::istream::read() and std::eek:stream::write() take a char* as
parameter, which can be annoying at times.
 
J

Jorgen Grahn

The C standard functions tend to use void* instead.

Yes; which APIs are you thinking of, Christopher? It might be
something that's common in your ecosystem (Windows? Unix? Something
else?) but it's (fortunately) not universal.

/Jorgen
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,813
Latest member
lawrwtwinkle111

Latest Threads

Top