문제

I am new to C and I have a question regarding a problem I have. I need to get this input: AA BB CC DD

But I get this all time AA BB CC00 DD

The code I am using is :

int main(void) {

 unsigned int   getal,temp;
        printf("Voer een getal in: \n");
        scanf("%0X",&getal);
        temp = getal & 0xFF000000;
        temp=temp>>24;

        printf("%0X\n", temp);
        temp = getal & 0xFF0000;
        temp=temp>>0xFF0;

        printf("%0X\n", temp);
        temp = getal & 0xFF00;
        temp=temp>>0xFF0000;

        printf("%0X\n", temp);
        temp = getal & 0xFF;
        printf("%0X\n", temp);

        return 0;

}

I appreciate all the help I can get!

도움이 되었습니까?

해결책

You mean temp >> 24, temp >> 16, and temp >> 8. Weird, you got the first one right, why did you suddenly do something totally different?

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top