0 votes 0 votes int main(void) { char p[20]; char *s = "Gate015"; int length = strlen(s); int i=0; for(i=0;i<length;i++) p[i]=s[length-i]; printf("%s",p); return 0; } Programming in C programming-in-c + – Keith Kr asked Dec 14, 2014 Keith Kr 358 views answer comment Share Follow See all 0 reply Please log in or register to add a comment.
Best answer 4 votes 4 votes printf("%s",p); %s prints all characters from the start address given by p till the first occurrence of '\0'; But p[0] = s[length - 0] = '\0'; So, nothing will be printed. The code can be corrected by for(i=0;i<length;i++) p[i]=s[length-i-1]; Arjun answered Dec 14, 2014 • selected Dec 16, 2014 by Keith Kr Arjun comment Share Follow See all 0 reply Please log in or register to add a comment.