X-Authentication-Warning: delorie.com: mailnull set sender to djgpp-bounces using -f From: Hans-Bernhard Broeker Newsgroups: comp.os.msdos.djgpp Subject: Re: String Problems Date: 24 Feb 2002 14:42:56 GMT Organization: Aachen University of Technology (RWTH) Lines: 42 Message-ID: References: <006f01c1bd25$839675c0$088f6518 AT mtww DOT phub DOT net DOT cable DOT rogers DOT com> NNTP-Posting-Host: acp3bf.physik.rwth-aachen.de X-Trace: nets3.rz.RWTH-Aachen.DE 1014561776 27441 137.226.32.75 (24 Feb 2002 14:42:56 GMT) X-Complaints-To: abuse AT rwth-aachen DOT de NNTP-Posting-Date: 24 Feb 2002 14:42:56 GMT Originator: broeker@ To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com Bill Henderson 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.