文字のバイト内のすべてのビットを右揃えにするコードをいくつか書きました。ただし、アプリケーションは行を実行しないため、ループに陥ります。positionmask<<1;
なぜこうなった?
void rjustify(char thisChar)
{
unsigned char c = thisChar;
unsigned char positionmask = 1;
unsigned char insertionmask = 1;
while(positionmask)
{
if(c & positionmask)
{
c^=positionmask;
c|=insertionmask;
insertionmask<<=1;
}
positionmask<<1; //This line is never executed.
}
printf("%c", &c);
}