This is the mail archive of the cygwin@sourceware.cygnus.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: BUG in function parameter passing ??????


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".


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]