VisionTek Interview Question: Whats is the difference betwe... | Glassdoor

Interview Question

Software Engineer Interview Hyderabad (India)

Whats is the difference between these two ? char* p

  = "Hello"; char* q = {'h', 'e', 'l', 'l', 'o'};
c language

Interview Answer

1 Answer


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)

Interview Candidate on May 17, 2012

Add Answers or Comments

To comment on this, Sign In or Sign Up.