VisionTek

  www.visiontek.com
Work in HR? Unlock Free Profile

VisionTek Software Engineer Interview Question

I interviewed in Hyderābād (India) and was asked:
"Whats is the difference between these two ? char* p = "Hello"; char* q = {'h', 'e', 'l', 'l', 'o'};"
Tags: c language
Add Tags [?]
Answer

Part of a Software Engineer Interview Review - one of 1 VisionTek Interview Reviews

Answers & Comments

0
of 0
votes

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

To comment on this question, Sign In with Facebook or Sign Up

Tags are like keywords that help categorize interview questions that have something in common.