Re: [Dev-C++] Pointer string declaration initialization problem (?)
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: Michal M. <mi...@mo...> - 2005-05-21 16:12:01
|
André Macário Barros wrote:
> Dear users,
> This is a simple question:
> Please, consider the following the two codes with
> their respective results:
>
> code 1:
> 1 -#include <stdio.h>
> 2 -#include <stdlib.h>
> 3 -#include <string.h>
> 4 -
> 5 -int main()
> 6 -{
> 7 - char *name="name1";
> 8 -
> 9 - printf("%s\n", name);
> 10- strcpy(name, "name2");
> 11- printf("%s\n", name);
> 12-
> 13- system("PAUSE");
> 14- return 0;
> 15-}
>
> execution results from code 1:
> Access violation as a consequence of line 10.
See documentation about -fwritable-strings
http://gcc.gnu.org/onlinedocs/gcc-3.4.4/gcc/C-Dialect-Options.html#index-fwritable_002dstrings-116
and AFAIK in gcc 4.0 this option was even removed
--
Regards,
Michal
ICQ# 175762750
|