--- In [email protected], "rodavilaca" <rodavil...@...> wrote:
>
> How to do this without having to check the condition c == 128 and then 
> do c = 1? 
> Is there some automated way? 

This doesn't use a condition- is it what you meant?

#include <stdio.h>

static unsigned char rotate8(unsigned char c)
{
    return (c << 1) + ((c & 128) >> 7);
}

int main(int argc, char *argv[])
{
    unsigned char c;

    for (c = 1; ; )
    {
        c = rotate8(c);

        printf("%02X\n", c);
    }
}

John

Reply via email to