What happens if I try to define a pointer which points to a string literal in C? -


this question has answer here:

for example,

char * first = "hello world!"; 

my questions is,

  1. is string literal stored in memory? (if guess pointer first address of inital element of string literal "hello world")

  2. if not, kind of random pointer value stored in first?

yes, string literals stored in memory. c , c++ standards string literals have static storage duration, attempt @ modifying them gives undefined behavior, , multiple string literals same contents may or may not share same storage.


Comments

Popular posts from this blog

amazon web services - S3 Pre-signed POST validate file type? -

c# - Check Keyboard Input Winforms -