Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

TheOne1

Char

This topic is 5570 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

The book I''m using (21 days) doesnt really give a good explanation on how to use char. Can anyone provide online references?

Share this post


Link to post
Share on other sites
Advertisement
Oh. Okay. Here's a quick example of code:


{
char thingie[50];

strcpy(thingie, "This string goes in the thingie.");

}

strcpy automatically makes it a shiny sz (string ended with zero, or a string that knows where it ends). I prefer char arrays to strings by far, but I'm abnormal.

As for math, char is just like an int that only holds -128 to 127 (or 0 to 256 if unsigned).

EDIT: Wrong numbers on char. Duh.

[edited by - Edward Ropple on June 19, 2003 5:25:51 PM]

Share this post


Link to post
Share on other sites
Oh. Yeah. Duh. Sorry. -128 to 127. (Used to Unicode. Fixed above post.)

Share this post


Link to post
Share on other sites
If CHAR_BIT = 8 (the minimum required by the standard), then

unsigned char = 0 - 255
signed char = -128 - 127
char = implementation defined as either unsigned char or signed char

Could cause portability problems if you assume char is equivalent to one or the other.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Take a look through this site it might help...

[link] http://www.opengroup.org/onlinepubs/007908799/xsh/string.h.html
[/link]

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
I could be wrong but I thought the standard defined char as always being one byte. You would only run into portability problems if the machine you were porting to didn’t use 8 bits to byte.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!