Mail Archives: djgpp/1997/12/14/11:48:13
Myknees wrote:
<SNIP>
> I am using RHIDE 1.4. I have no optimization going on. When I run
> the program with Ctrl-F9, I get an unexpected result:
>
> "The string itself." backwards is:
> xxxxxxxxxxxxxxxxxx
>
> ...However, when I use F7 to step through the program, it works fine
> and prints the following to the screen:
>
> "The string itself." backwards is:
> .flesti gnirts ehT
the subjet of your post is actually a comp.lang.c FAQ. i would suggest
you find it and read it. as for your problem:
> for (len=0; s[len]!='\0'; len++)
> ; //len = length of s.
well, this is not it put there is something called strlen you know.
>
> //copy is the name of the address of the first element:
> char *copy;
> copy[len]='\0'; //give copy string a terminal nul
>
> /* Next I initialize the copy string to "xxxxx..." so
> that I can watch it easily when debugging. */
> for (i=0; i<len; i++){
> copy[i]='x';
> }
hmmm ... where does the memory come from?
you must realize that basic C questions such as this are off-topic for
this newsgroup.
in any case, i presume you are running under windows95. if you had been
in dos with cwsdpmi, your program would have crashed with a sigsev. from
the traceback, you would see exactly where you the illegal access was
occuring. windoows 95's dpmi server is broken, and let's you write
whereever you want, that's why your program seems to work at all.
--
----------------------------------------------------------------------
A. Sinan Unur
Department of Policy Analysis and Management, College of Human Ecology,
Cornell University, Ithaca, NY 14853, USA
mailto:sinan DOT unur AT cornell DOT edu
http://www.people.cornell.edu/pages/asu1/
- Raw text -