string assignment in C

Peter da Silva peter at ficc.uu.net
Sat Oct 15 01:01:07 AEST 1988


In article <6777 at chinet.chi.il.us>, john at chinet.chi.il.us (John Mundt) writes:
> Now, this would be different:

> char p[] = { 't','h','i','s',' ','a',' ','s','t','r','i','n','g','\n' };

> main()
> {
> 	printf(p);
> }

Different all right. You forgot to terminate your string. Your milage
will vary, but I got:

% a.out | vcat
this a string
l&^Z'.^R% []

[] is the cursor.
-- 
Peter da Silva  `-_-'  Ferranti International Controls Corporation.
"Have you hugged  U  your wolf today?"            peter at ficc.uu.net



More information about the Comp.lang.c mailing list