From: cgw AT pgt DOT com (Charles G Waldman) Subject: BUG in function parameter passing ?????? 28 Aug 1998 00:09:16 -0700 Message-ID: <13798.2205.894237.157257.cygnus.gnu-win32@sirius> References: <98082711213612 AT psicla DOT psi DOT ch> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit To: Mark DOT Koennecke AT psi DOT ch Cc: GNU-WIN32 AT cygnus DOT com Mark DOT Koennecke AT psi DOT ch writes: > > 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"); > Because the string "Hello You" is a constant, and is allocated in the read-only segment of the executable. The buffer pBuffer is allocated read/write. This is done so that storage for literal strings can be shared between object files. There's a compiler option to turn off this behavior. Try adding -fwritable-strings to your compilation flags. - 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".