Read the FAQ on bit shifting. While you're at it, read the FAQ on why void main is wrong.Quote:
Originally Posted by draggy
Quzah.
Printable View
Read the FAQ on bit shifting. While you're at it, read the FAQ on why void main is wrong.Quote:
Originally Posted by draggy
Quzah.
Quote:
Originally Posted by quzah
most important partCode:int main()
{
unsigned char a = 'a';
unsigned char c = 0;
unsigned char b[8];
char mask = 1;
int i;
for(i = 8; i > 0; i--)
{
printf("%d", a & mask);
b[i - 1] = a & mask;
a >>= 1;
}
printf("\n");
for(i = 0; i < 8; i++)
{
c |= b[i];
c <<= 1;
if(b[i] == 1)
{
printf("1");
}
else
{
printf("0");
}
}
printf("\n%c\n", c);
return 0;
}
nothing change still get the same old error result....Code:c |= b[i]; //means c = c | b[i];
c <<= 1;//means c = c << 1;
Fascinating I'm sure, but what exactly do you expect to get? People sure don't know how to ask people to help them. Picture a conversation with someone:
You: This doesn't work.
Them: That's nice.
You: Fix it.
Them: What's wrong?
You: This doesn't work.
That's all well and good, but how about you actually tell us a bit more. How about we take a different turn in our conversation?
You: This doesn't work.
Them: That's nice.
You: Fix it.
Them: What's wrong?
You: Well I input this, and I'm supposed to get this. But I don't, I get that instead.
See how much better that is? Now you try.
Quzah.
Since I'm such a nice guy, here's a hint:?uoy naC .tahw tuo erugif etiuq t'nac I .senil owt esoht htiw gnorw gnihtemos evah uoy ,revewoh ,trap tcerroc eht detouq evah ot mees uoYQuote:
most important part
Code:c |= b[i]; //means c = c | b[i];
c <<= 1;//means c = c << 1;
Quzah.
fixed the problem...
Thanks
ahahahaQuote:
Originally Posted by quzah
Interesting way to get your point accross. :p