Pergunta de entrevista da empresa VisionTek

Whats is the difference between these two ? char* p = "Hello"; char* q = {'h', 'e', 'l', 'l', 'o'};

Resposta da entrevista

Sigiloso

18 de mai. de 2012

first one is a character string, C automatically adds null character in the end. And it needs to be "const char* p" instead of just "char*" because compiler may put this on read only memory. You can never guarantee that it can be modified later. (but interviewer was least interested in knowing that)