X-Authentication-Warning: delorie.com: mailnull set sender to djgpp-bounces using -f Message-ID: <003601c1bd50$1f59d9a0$088f6518@mtww.phub.net.cable.rogers.com> From: "Bill Henderson" To: djgpp AT delorie DOT com References: <006f01c1bd25$839675c0$088f6518 AT mtww DOT phub DOT net DOT cable DOT rogers DOT com> Subject: Re: String Problems Date: Sun, 24 Feb 2002 11:27:14 -0500 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 5.50.4807.1700 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4807.1700 Reply-To: djgpp AT delorie DOT com Thanks for the response Hans-Bernhard. It was much appreciated. However, the printf( "\ncharacter %n == %s ", i, ch[i] ) ; in the loop was intended to dump the character to the screen and not put it into a file....... But let me rephrase my question very simply: How do I put a percent (%) character into a file? Given that the attempts as per my original post do not work. Thanks in advance Bill Henderson ----- Original Message ----- From: "Hans-Bernhard Broeker" Newsgroups: comp.os.msdos.djgpp To: Sent: Sunday, February 24, 2002 9:42 AM Subject: Re: String Problems > 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.