Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > how to convert an unsigned char to byte

Reply
Thread Tools

how to convert an unsigned char to byte

 
 
Tim Rentsch
Guest
Posts: n/a
 
      10-04-2005
Jack Klein <> writes:

> On Thu, 29 Sep 2005 00:40:06 +0200, Skarmander
> <> wrote in comp.lang.c:
>
> > Flash Gordon wrote:
> > > QQ wrote:
> > >
> > >> I know a char is 2 bytes, the conversion is like
> > >
> > >
> > > Not in C it isn't. In C a char is 1 byte by definition, although that
> > > byte can be more than 8 bits.
> > >

> > But, for completeness, not less. And see below -- a char *may* be two
> > bytes, depending on how you define "byte". (How the OP defines it is
> > anyone's guess.)

>
> No, it may not, not in C and not among actually literate computer
> professionals.
>
> If a char contains more than 8 bits, it is certainly larger than on
> "octet", and may indeed be two or even four "octets" in size.


The statement about how computer professionals use the term byte
doesn't match my experience. In most cases (80%, perhaps?), most
computer people I know use "byte" to mean 8 bits, or at least to mean
8 bits unless stated otherwise (eg, "10 bit bytes", as opposed to just
"bytes"). And the sorts of people I'm thinking of certainly would
qualify as literate.

Of course what Jack about the term "byte" is right in the context of
discussing Standard C. For a broader audience, however, it's reasonable
to expect that many of them will take "byte" to mean 8 bits unless there
is an explicit statement giving another meaning to the term.
 
Reply With Quote
 
 
 
 
Old Wolf
Guest
Posts: n/a
 
      10-05-2005
Emmanuel Delahaye wrote:

> QQ wrote on 28/09/05 :
> > I know a char is 2 bytes, the conversion is like

>
> What ? An unsigned char is very likely a byte to me. BTW, there is no
> 'byte' type in C. Maybe, on your implementation or application, you
> have a byte type that have the size of 2 char, but it's very stressy.
>
> > byte[] byte_array = new byte[2*char_length]; //Allocate double mem as

>
> Wait a minute. We are takling C here. If you want C++, please knock
> next door.


The statement is a syntax error in C++ . Try knocking on
some other newsgroup. (I can't recommend comp.lang.java.programmer,
which seems to have a worse S:N ratio than Mabden)

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
Casting from const pair<const unsigned char*, size_t>* to constpair<unsigned char*, size_t>* Alex Vinokur C++ 9 10-13-2008 05:05 PM
Linking error LNK2001 - "__declspec(dllimport) private: void __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::_Tidy(unsigned short)" (__imp_?_Tidy@?$basic_string@DU?$char_ sharmadeep1980@gmail.com C++ 1 07-07-2006 07:27 AM
How to byte[ ] --> char[ ] and char[ ] --> byte[ ]? Richard Java 11 02-01-2006 07:34 AM
void*, char*, unsigned char*, signed char* Steffen Fiksdal C Programming 1 05-09-2005 02:33 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57