linux-c-programming.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* How to check if char pointer is a constant!?
@ 2016-07-07 19:40 Daniel.
  2016-07-07 20:26 ` Phil Sutter
  0 siblings, 1 reply; 5+ messages in thread
From: Daniel. @ 2016-07-07 19:40 UTC (permalink / raw)
  To: linux-c-programming@vger.kernel.org

Hi everybody,

I have some function, say
void empty(char *p) { p[0] = '\0'; }

If I call it like this empty("Hello") it will segfaults since "Hello"
is put in readonly section of the program. Is there a way to check for
this?! Maybe some nasty gcc extension!?

Regards,

-- 
"Do or do not. There is no try"
  Yoda Master

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2016-07-08 14:01 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-07-07 19:40 How to check if char pointer is a constant!? Daniel.
2016-07-07 20:26 ` Phil Sutter
2016-07-08 12:33   ` Daniel.
2016-07-08 12:59     ` Phil Sutter
2016-07-08 14:01       ` Daniel.

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).