strtok segfaults in CLI but not in GDB

K

Keith Thompson

Keith Thompson said:
That will cause gcc to emit a warning message if it can determine at
compilation time that you've attempted to modify a string literal.

[long explanation snipped]

To be fair, though, it will cause a warning to be generated for the
original code in question.
 
D

Dave Vandervies

CBFalconer said:
Pietro Cerutti wrote:
So, it should be declared as

char input1[14] = "Hello, World!";

Better is: "char input[] = "Hello, World!";", which is immune to
changing the actual string.

What sort of nonsense was I writing here?

It doesn't look all that much like nonsense to me, though it might help
that my interpretation was informed by a good guess at what you meant.
(If the length of the initializer string changes, then the `char
arr[]="string"' form doesn't need the array size to be adjusted to match.)


dave
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,020
Latest member
GenesisGai

Latest Threads

Top