TIP: Click on subject to list as thread! ANSI
echo: aust_c_here
to: david nugent
from: Simeon Cran
date: 1994-02-25 08:16:34
subject: printf an long integers

Hi david

 >> I'm trying to show the size of a file with ftell() and printf().
 >> Something like:
 >> printf("The file is %u bytes long", ftell(filename));
 >> works ok until the file gets larger than 64k.

 dn> RTFM, "%lu".

I read it, tried various things, but I can't work it out. %lu doesn't work.
It leaves that field blank. If I use %u it works fine up to 64k then
overflows.

This is QuickC for Windows in Ansi mode. If you reckon that %lu definitely
works could you post a quick and dirty program which shows the size of a
file using %lu and I'll compile it on QuickC and see what happens.

("The file is %u bytes long", ftell(filename));   ...causes
overflow after 64k.

("The file is %lu bytes long", ftell(filename));  ...causes an
extra space between
                                                     "is" and
"bytes"!

 >> Then the
 >> unsigned integer of %u is too small. Is there a way of
 >> getting printf to handle the long integer, or do I have to
 >> convert the number to a string first?

 dn> That's precisely what printf() does - converts types to ascii. :-)

Yeah, I know, but it seems like my version doesn't handle long integers...
seems that way. I'm ready to be corrected if I've missed something!

Simeon.


--- Sqed/32 0.87/r15030

* Origin: Home of MyZ80 (3:640/236)
SEEN-BY: 50/99 54/54 620/243 623/630 640/201 206 208 236 297 305 316 531 556
SEEN-BY: 640/590 820 821 823 890 690/660 711/409 430 807 808 809 932 934
SEEN-BY: 712/623 713/888 714/906 800/1
@PATH: 640/236 208 297 820 711/409 54/54 711/808 809 934

SOURCE: echomail via fidonet.ozzmosis.com

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.