Re: Division in loop

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

Randi Botse wrote:

> void *buffer; /* buffer, will be allocated */
> ...

>        ret = read(fdp, buffer + bytes, stat.st_size - bytes);

Pointer arithmetic on a void* is undefined. gcc allows this as an
extension, treating void* like char*, i.e. p+i is treated as

For portability, define buffer as a char*.

>        printf("\rcompleted: %i%%", progress); /* NO OUTPUT, UNTIL LOOP ENDED */
>        fflush(stdout);

> Then i see printf() never output the message until the loop has ended...
> 'fdp' is a file descriptor to a local file, i send it through a serial
> connection (RS232),

Try checking the return value of printf() and fflush(), and errno upon

Also, what is stdout connected to? A VT? An xterm? sshd?

Glynn Clements <glynn@xxxxxxxxxxxxxxxxxx>
To unsubscribe from this list: send the line "unsubscribe linux-c-programming" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at

[Linux Assembler]     [Git]     [Kernel List]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [Yosemite Campsites]     [Yosemite News]     [GCC Help]

Add to Google Powered by Linux