delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/09/19/21:23:54

From: "Kilgore Trout" <kevind AT netcore DOT ca>
Newsgroups: comp.os.msdos.djgpp
References: <37e52e96 AT news DOT wincom DOT net> <37E545EC DOT EA685B4A AT hmc DOT edu>
Subject: Re: Problem with strcat
Lines: 36
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 5.00.2314.1300
X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2314.1300
X-Original-NNTP-Posting-Host: c-xix.wincom.net
Message-ID: <37e587ba@news.wincom.net>
Date: Mon, 20 Sep 1999 00:49:35 GMT
NNTP-Posting-Host: news.wincom.net
NNTP-Posting-Date: Sun, 19 Sep 1999 20:49:35 EST
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

thanks, i've got it working now.

kev

Nate Eldredge <neldredge AT hmc DOT edu> wrote in message
news:37E545EC DOT EA685B4A AT hmc DOT edu...
> Kilgore Trout wrote:
> >
> > Hello,  I am working on a school assignment and have run into a small
> > problem with djgpp.  The purpose of the program is to take a number less
> > than 80 typed out in words (such as 'twenty two'), convert it to and
> > integer, add seventeen, and convert the integer back into words.  I run
into
> > a problem if I run the program and input a number greater than or equal
to
> > 'seventy four'.  I have tried compiling with two other compilers (lcc
and
> > cc) and the program has worked fine.  I think that the problem may be in
the
> > line
> >   strcat(output_string, integer_to_words(number));
> > Any help is greatly appreciated.
>
> The string returned from `integer_to_words' is a constant (since it came
> from a literal).  You assign it to `output_string' and then try to
> modify it, which is a no-no.  Not only is it constant, but there is no
> space for additional characters, so you overwrite something else.
>
> You'll have to create some writable space for it (an array or use
> `malloc').
> --
>
> Nate Eldredge
> neldredge AT hmc DOT edu


- Raw text -


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