Re: write a multidimensional array in a file



On Wed, 13 Jul 2005 13:48:26 -0700, Barry Schwarz <schwarzb@xxxxxxxxx>
wrote:

> On 12 Jul 2005 23:51:49 -0700, steph_de_marseille@xxxxxxxx wrote:
<snip>
> > fprintf(file1,"%f %f\ %f %f \n",array[i][0],array[i][1]);
>
> This contains a syntax error and invokes undefined behavior.
> Backslash-blank is not a valid escape sequence like \n. You have four
> format specifiers but only two arguments t6o satisfy them.

Nit: the (or any) syntax error also invokes UB, but if this phrasing
was meant to say that the extra arguments to fprintf() cause UB,
that's wrong. They're safely discarded (7.19.6.1p2) just as they are
for other (user) vararg functions. Unless of course the arguments
cause UB within themselves, like two assignments to same object.

- David.Thompson1 at worldnet.att.net
.