Subject: Re: BUG in function parameter passing ??????
From: [email-masked] (Michael Weiser)

29 Aug 1998 00:56:00 -0700
Message-ID: <[email-masked]>
References: <[email-masked]>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
To: [email-masked]
Cc: [email-masked]

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
"[email-masked]" with one line of text: "help".