in Programming in C
638 views
6 votes
6 votes

What is the output of this program?

#include <stdio.h>
int main()
{
	char *ptr;
	char string[] = "Hello 2017";
	ptr = string;
	ptr += 4;
	printf("%s",++ptr);
} 
  1. Hello 2017
  2. ello 2017
  3.  2017
  4. o 2017
in Programming in C
by
638 views

2 Answers

2 votes
2 votes
Best answer
ptr += 4; // leave 4 element
printf("%s",++ptr); //increment pointer.

i.e. leave 5 element and after that print untill null is encountered.
 2017
selected by
0 votes
0 votes
initialy ptr point to H

string will be start printing after 5 character from H

so o/p is 2017
Answer:

Related questions