www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2002/02/24/12:30:46

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" <inconnu AT softhome DOT net>
To: djgpp AT delorie DOT com
References: <006f01c1bd25$839675c0$088f6518 AT mtww DOT phub DOT net DOT cable DOT rogers DOT com> <a5au5g$qph$1 AT nets3 DOT rz DOT RWTH-Aachen DOT DE>
Subject: Re: String Problems
Date: Sun, 24 Feb 2002 11:27:14 -0500
MIME-Version: 1.0
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" <broeker AT physik DOT rwth-aachen DOT de>
Newsgroups: comp.os.msdos.djgpp
To: <djgpp AT delorie DOT com>
Sent: Sunday, February 24, 2002 9:42 AM
Subject: Re: String Problems


> 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 -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019