Hello,

If you will comple with gcc (version lower than 4) a program like this , on Linux:

int main()
    {
     char* myString = "test";
    (*myString)++;

    }

You will get a segfault when running it.
On the other hand, if you will pass -fwriteable-strings at compilation ,
you will be able to run it without any segfault .
They do say in the man gcc that writeable-strings is deprecated and it is better not to
use it.


According to gcc-4.0 docs,
"GCC no longer accepts the -fwritable-strings option. Use named character arrays when you need a writable string."


see
http://gcc.gnu.org/gcc-4.0/changes.html

I have 2 questions:

What are the disadvantages of using -fwritable-strings and why was it removed ?


by "Using named character arrays" I assume that the meaning is writing char myString[] = {"test"};

am I right ?

Regards,
Sting

_________________________________________________________________
Don't just search. Find. Check out the new MSN Search! http://search.msn.click-url.com/go/onm00200636ave/direct/01/




Reply via email to