Mail Archives: djgpp/2002/02/24/09:47:09
Bill Henderson <inconnu AT softhome DOT net> wrote:
> (1) Why will the following code output to the screen perfectly (with
> the percent symbol output correctly either escaped or not), whilst
> it is impossible to place the percent character into a file which
> produces:
It definitely is possible, but you're trying it the wrong way. Note the difference
between:
> printf( "\ncharacter %n == %s ", i, ch[i] ) ;
^^^ ^^^^^
and:
> fprintf( fp, ch[i] ) ;
^^^^
There's no "%s" format anywhere, in the fprintf() case.
fprintf(fp, "%s\n", ch[i]);
would have been closer to the goal. An alternative would have been
fputs(ch[i], fp); fputc('\n', fp);
or fputc(ch[i][0], fp); fputc('\n', fp);
> (2) Is it really necessary to use arrays to satisfactorily
> manipulate strings?
Yes. Strings *are* arrays in C.
> (3) I notice getchar() misbehaving
[...]
Sorry, but without explaining what the "misbehaviour" was, it's hard
to help you here.
--
Hans-Bernhard Broeker (broeker AT physik DOT rwth-aachen DOT de)
Even if all the snow were burnt, ashes would remain.
- Raw text -