From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: fee84,80ae9f89712e54ee X-Google-Attributes: gidfee84,public X-Google-Thread: 1014db,80ae9f89712e54ee X-Google-Attributes: gid1014db,public From: Alun.Champion@bridge.bst.bls.com (Alun Champion) Subject: Re: printf-problem Date: 1996/01/17 Message-ID: #1/1 X-Deja-AN: 135592439 distribution: world references: <4dj4g6$t9f@sunsystem5.informatik.tu-muenchen.de> organization: Computer People Inc. newsgroups: comp.unix.osf.osf1,comp.lang.c In article <4dj4g6$t9f@sunsystem5.informatik.tu-muenchen.de> wist@lam.mw.tu-muenchen.de (Henrik Wist) writes: : long int zahl; /* which is e.g. 10000500001 */ : printf("%d\n",zahl); /* gives 1410565409, which is definitly wrong */ Though the FAQ goes into a lot of detail about printf and scanf, but it sort of misses this one. The closes it gets is in the answer to "How can I convert numbers to strings (the opposite of atoi)?" In the answer it says :- You can obviously use sprintf() to convert long or floating- point numbers to strings as well (using %ld or %f). I suppose the answer is there ;') Anyway the answer is %d is the printf specifier for ints not longs %ld is the printf specifier for longs. Man pages and/or almost any book on 'C' could have told you this. Regards -A. -- | A.Champion |