Below is the code for which I want to know the answer to 2 questions in the side comment. Please help me
#include<iostream>
using namespace std;
int main()
{
char *p="Hello";
cout <<*p; //gives H
cout <<*(p++); //also gives H.Why?
cout <<*(p++); //gives e.
cout <<*(p++); //gives l.
cout <<*(p++); //gives l.
cout <<*(p++); //gives o.
cout <<*(p++); //gives no output.Why? It should give some garbage value!
}
const char *, notchar *.x++returns the old value ofxand increments it. Also look up null termination.hello\0.Let me ask If I add another linecout <<*(p);i still get no output ,instead of some garbage.Is it related to undefined behaviour?