Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Posting-Version: version B 2.10.1 6/24/83; site umcp-cs.UUCP
Path: utzoo!watmath!clyde!burl!ulysses!allegra!mit-eddie!think!harvard!seismo!umcp-cs!chris
From: chris@umcp-cs.UUCP (Chris Torek)
Newsgroups: net.lang.c
Subject: Re: What is wrong with this program?
Message-ID: <1284@umcp-cs.UUCP>
Date: Sat, 17-Aug-85 19:03:18 EDT
Article-I.D.: umcp-cs.1284
Posted: Sat Aug 17 19:03:18 1985
Date-Received: Tue, 20-Aug-85 06:49:03 EDT
References: <117@graffiti.UUCP> <353@ttrdc.UUCP> <9940@ucbvax.ARPA>
Distribution: net
Organization: U of Maryland, Computer Science Dept., College Park, MD
Lines: 20

>... you are forgetting that the format "%.8s" will cause printf to
>print up to a null or 8 chars max.  Unfortunately this style of
>printf can not be used with sizeof for compile time format changes
>without run time code support.

Well, you can always use:

	printf("%.*s", sizeof (utmp.ut_name), utmp.ut_name);

or if you want exactly sizeof (utmp.ut_name) characters:

	#define NMAX (sizeof (utmp.ut_name))

	printf("%-*.*s", NMAX, NMAX, utmp.ut_name);

(The "-" gives "left adjustment"---blank filling at the right.)
-- 
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 4251)
UUCP:	seismo!umcp-cs!chris
CSNet:	chris@umcp-cs		ARPA:	chris@maryland