There are several other problems with your code.
Pointers are usually used to point to data that already exists, so you can use it like this
char arr[] = "C++";
char* t = &arr[0];
Also modifiable,
t[1] = 'p';
t[2] = 'p';
of course there is a special way of using string —— let the pointer point to a string constant. Just the way you used:
char *t = "C++"; // you cannot modify it in most operating systems
t[1] = 'p';
t[2] = 'p';
There is a better way of using it, which is more portable and easy to understand:
const char* t="C++";
2.You code have many place that is not in c standard
#include // You'd better add a space between, for this is a good coding convention
#include // only supported by vc/vs in windows, you can use getchar() instead
int main() // main returns int
{
char* t = "C++";
t[1] = 'p';
t[2] = 'p';
printf("%s\n", t); // it's a good habit to add a '\n' when printing a string
getchar(); // getchar() is supported by c standard library
return 0; // return 0 here
}
3.about printing string
Linux is line-buffered(ignore this if you are using windows :P) & for easier to read in console, you'd better add a '\n' at the end of you printed string:
printf("%s\n",t);
If you don't want to have a carriage return after a string. In windows use just as you like:
printf("%s",t);
In Linux, you should add a fflush() in stdlib.h.
printf("%s",t);
fflush(stdout);