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

ruby on rails - ActiveRecord order not working -

java - AEM: 403 Forbidden occurs when call a Post servlet -

How to embed a map into Netlogo using GIS extension? -