From: michael@weiser.saale-net.de (Michael Weiser)
Subject: Re: BUG in function parameter passing ??????
29 Aug 1998 00:56:00 -0700
Message-ID: <199808281159.NAA29191.cygnus.gnu-win32@weiser.saale-net.de>
References: <98082711213612@psicla.psi.ch>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
To: Mark.Koennecke@psi.ch
Cc: gnu-win32@cygnus.com

Hallo Mark, you wrote:
>int main(int argc, char *argv[])
>{
>  char pBuffer[132];
>  
>  /* why does this work? */
>  strcpy(pBuffer,"Hello You");
>  strtolower(pBuffer);
>  
>  /* but this gives a segmentation violation under Cygwin*/
>  strtolower("Hello You");
>  
>  printf("Success\n");
>  
>}

You're trying to change a global allocated string constant that AFAIK
isn't guaranteed to be changeable on any system and compiler. IMHO I
sometime read something about systems that protect their global
constants against changing which could be happening here with NT.

Just try something like:

int main(int argc, char *argv[])
{
  char pBuffer[] = "Hello you";
  
  strtolower(pBuffer);
  
  printf("Success\n");
}

or

char pBuffer[] = "Hello you";

int main(int argc, char *argv[])
{
  strtolower(pBuffer);
  
  printf("Success\n");
}

Then you're changing an global or local array which should work on any
system. But perhaps there's a compiler switch somewhere...

Any comments from the experts? :)
-- 
bis denne, Michael
Elefanten spielen nicht Schach!
-
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request@cygnus.com" with one line of text: "help".
