From: Randi Botse <nightdecoder@gmail.com>
To: Glynn Clements <glynn@gclements.plus.com>
Cc: linux-c-programming@vger.kernel.org
Subject: Re: Division in loop
Date: Thu, 10 Sep 2009 14:01:18 +0700 [thread overview]
Message-ID: <34e1241d0909100001u4a3b338crf225e7fc9083a806@mail.gmail.com> (raw)
In-Reply-To: <19112.19543.594103.477988@cerise.gclements.plus.com>
Thanks Glynn for let me know that the void* pointer arithmetic is
undefined, and gcc automatically cast it to char* pointer... is this
because void* doesn't have a size? im curious when i do sizeof(void*),
my machine tell me sizeof(void*) is 4kb... i thnk when i do (void* +
1) that's means "4 kb after void*"?....
i run the code in GNOME terminal, that's means stdout connected to xterm?
On Thu, Sep 10, 2009 at 7:46 AM, Glynn Clements
<glynn@gclements.plus.com> wrote:
>
> 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
> (void*)((char*)p+i).
>
> 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
> error.
>
> Also, what is stdout connected to? A VT? An xterm? sshd?
>
> --
> Glynn Clements <glynn@gclements.plus.com>
>
next prev parent reply other threads:[~2009-09-10 7:01 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-09-08 14:40 Division in loop Randi Botse
2009-09-08 14:47 ` Saurabh Sehgal
2009-09-08 14:57 ` Bert Wesarg
2009-09-08 14:58 ` Tim Walberg
2009-09-08 15:09 ` Randi Botse
2009-09-09 0:49 ` Glynn Clements
2009-09-09 2:37 ` Randi Botse
2009-09-09 2:39 ` Randi Botse
2009-09-09 2:52 ` Eric Bambach
2009-09-09 2:57 ` Eric Bambach
2009-09-09 10:12 ` Randi Botse
2009-09-10 0:46 ` Glynn Clements
2009-09-10 7:01 ` Randi Botse [this message]
2009-09-10 7:03 ` Manish Katiyar
2009-09-11 7:26 ` Glynn Clements
2009-09-09 0:45 ` Zhenwen Xu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=34e1241d0909100001u4a3b338crf225e7fc9083a806@mail.gmail.com \
--to=nightdecoder@gmail.com \
--cc=glynn@gclements.plus.com \
--cc=linux-c-programming@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).