Mail Archives: djgpp/1999/09/19/21:23:54
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 -