while(p)
is the same as
while(p != NULL)
which is of course always true - the string literal points to a valid memory location. I feel you are confusing this with
while(*p)
or with the equivalent
while(*p != 0)
because that would run until it finds the 0-terminator in the string. That's not good enough either, though. You don't know which string you just printed. You have to keep track of the number of strings manually. Also, why print it character-by-character, invoking the quite expensive printf() function for every byte you display? It's just wasteful. How about something like
char szStr[] = "India\0Japan\0America\0Australia";
char *p = szStr;
for (int i = 0; i < 4; i++) {
puts(p);
p += strlen(p) + 1;
}
Still, I don't see why this is simpler or otherwise better than simply storing an array of strings. Like this:
const char *strings[] = {
"India",
"Japan",
"America",
"Australia"
};
for (int i = 0; i < sizeof(strings) / sizeof(strings[0]); i++)
puts(strings[i]);
char * szStr[] = {"India", "Japan", "America", "Australia"};. Then use%sin theprintf, not%c. And you'll need a different way of knowing when to stop.