delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/1998/08/29/00:56:00

From: michael AT weiser DOT saale-net DOT 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 AT psicla DOT psi DOT ch>
Mime-Version: 1.0
To: Mark DOT Koennecke AT psi DOT ch
Cc: gnu-win32 AT cygnus DOT 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 AT cygnus DOT com" with one line of text: "help".

- Raw text -


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