C
1 Answer
C
| Flag | PURGE
when we write printf(5+"HelloIam")..it prints Iam
but when it is like printf("%s",5["HelloIam"]).. then it leads to segmentation fault...please explain..
Email me when people comment.
Email me when people comment.
Loading...
An error occurred in subscribing you.
Email me when people comment.
Email me when people comment.
Loading...
An error occurred in subscribing you.
CareerCup is the world's biggest and best source for software engineering interview preparation. See all our resources.
printf(5+"HelloIam") means print the character from 5 pos onwards till the end of the given string.
- hprem991 April 19, 2013printf("%s",5["HelloIam"]) means print 5 element from the array [""], unfortunately your array is short of the element as you have only one element declared inside the array.i.e. within a quote, Hence compiler won't able to find the element being asked creating segmentation.