int i;
char str[100];
char *p;
puts("Enter a string:");
gets(str);
system("cls");
p = &str;
for (i = 0; i < strlen(str); i++) {
printf("\n%s", p);
++p;
//printf("\n%d %d", i, *p);
}
for (i=2*i+1; i > strlen(str); i--) {
printf("%s\n", p);
p--;
//printf("\n%d %d", i, *p);
}
The output of this program is
"alpine
lpine
pine
ine
ne
e
e
ne
ine
pine
lpine
alpine".
How to make it display 'e' only once, not twice?