Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!husc6!uwvax!umn-d-ub!umn-cs!ems!pwcs!zycad!kjb From: kjb@zycad.UUCP (Kevin Buchs) Newsgroups: comp.lang.c Subject: printf and variable length string format (asterisk) Message-ID: <692@zycad.UUCP> Date: Sun, 22-Nov-87 10:35:27 EST Article-I.D.: zycad.692 Posted: Sun Nov 22 10:35:27 1987 Date-Received: Wed, 25-Nov-87 20:43:01 EST Organization: ZYCAD, Oakdale, MN Lines: 30 I want to print out a string whose length I will not know ahead, and which is not null terminated. I thought the following use of the asterisk precision delimiter would work: char *a = "hello"; int i; for (i=0; i<6; i++) printf("%*s\n", i, a); I thought it would print: h he hel hell hello but I got: hello hello hello hello hello Does the asterisk not work with the s descriptor? Or, am I using it wrong. Is there another way to do this (except fwrite)? -- Kevin Buchs 3500 Zycad Dr. Oakdale, MN 55109 (612)779-5548 Zycad Corp. {rutgers,ihnp4,amdahl,umn-cs}!meccts!nis!zycad!kjb