[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [avr-gcc-list] file hex form converter reference

From: rusty+avr-gcc-list
Subject: Re: [avr-gcc-list] file hex form converter reference
Date: Sun, 28 Nov 2004 20:35:48 -0800 (PST)

Here's something that reads standard input and writes standard output,
written in plain old c.  I'm guessing your problem is that the
variable you were using with getchar was a char instead of an int, and
you need to mask off the high bytes when you give it to printf.

# include <stdio.h>

main(int argc, char **argv) {
    int        ch, i;

    i = 0;

    while ((ch = getchar()) != EOF) {
        fprintf(stdout, "0x%02x, ", (0xff & ch));
        if (i++ > 8) {
            fprintf(stdout, "\n");
            i = 0;

reply via email to

[Prev in Thread] Current Thread [Next in Thread]