I've never written byte variables on my unix shell before, so I don't know if it works or not. I'd been using unsigned ints to get hex numbers as input but I was having trouble with what my input actually was. My friend told me to use byte variables instead because they have 8 bits. MY problem is I tried to declared them every way I could find and nothing worked, I tried byte* var, byte *var, Byte var, Byte* var, BYTE* var, BYTE var, even (BYTE *) var; and nothing worked. What the hell?? I just tried unsigned in front of it and no change. Am I supposed to include a special library? What's going on.

Incase this really doesn't work, my code uses fscanf to read the number. When I was reading them as unsigned ints and printing them at the same time, they didn't look anything like the hex numbers I need. I checked the file and it didn't look weird at all. I figured byte would solve my problem.

>My friend told me to use byte variables instead because they have 8 bits.
A byte doesn't have to be 8 bits.

>What the hell??
C doesn't have any kind of "byte" keyword. If you want a byte, use unsigned char.

>I figured byte would solve my problem.
Somehow I doubt that using a narrower type will help. Perhaps if you posted your code, along with the input and your expected output, we can help you figure out what the real problem is.

Boy do I feel stupid. I was printf-ing the hex numbers with d, not x. Now that I know what I'm gonna be looking at I'm going to work a bit more on it. If I can't figure it out I'll post here soon.

>My friend told me to use byte variables instead because they have 8 bits.
A byte doesn't have to be 8 bits.

Are you sure? (curious)

The standard only requires that CHAR_BIT be a minimum of 8.

5.2.4.2.1 Sizes of integer types <limits.h>
1 The values given below shall be replaced by constant expressions suitable for use in #if
preprocessing directives. Moreover, except for CHAR_BIT and MB_LEN_MAX, the
following shall be replaced by expressions that have the same type as would an
expression that is an object of the corresponding type converted according to the integer
promotions. Their implementation-defined values shall be equal or greater in magnitude
(absolute value) to those shown, with the same sign.
— number of bits for smallest object that is not a bit-field (byte)
CHAR_BIT 8

Some embedded DSP chips have 32-bit chars (and 32-bit everything else) for example.

Some embedded DSP chips have 32-bit chars (and 32-bit everything else) for example.

Wow! They must be for Chinese :)

>Are you sure?
Quite.

Oh, where is the explanation? :(

Oh, where is the explanation? :(

In the ISO standards -- read Salem's post above, but I guess you did not or you would not have asked this question.

>Oh, where is the explanation?
You didn't ask for one. You asked if I was sure, which I am. If you want details, go read the C99 draft standard, though Salem already quoted the relevant section.

Next time try reading for comprehension before asking inane questions.

Yes, I am sorry. This is the C forum, so I should have known you were talking about the byte data type.

>Oh, where is the explanation?
You didn't ask for one. You asked if I was sure, which I am. If you want details, go read the C99 draft standard, though Salem already quoted the relevant section.

Next time try reading for comprehension before asking inane questions.

This has got to be the most obnoxious post I have ever seen... Do you have control issues?

>This has got to be the most obnoxious post I have ever seen...
I guess you don't read many posts. I can be much more obnoxious than that, and I've seen other people say things that I wouldn't dare.

>Do you have control issues?
I'm not sure that's relevant, but no.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.