#include "stdio.h"
static void PrintLine(void)
{
int loop_a = 30;
printf("/n");
while (loop_a--)
{
printf("-");
}
}
static void PrintStrAndLine(char *str, int type)
{
if (type == 1)
{
while (*str)
{
printf("/n/t*p++ = %c", *str++);
}
}
else if (type == 2)
{
while (*str)
{
printf("/n/t*(p++) = %c", *(str++));
}
}
else if (type == 3)
{
while (*str)
{
printf("/n/t(*p)++ = %s", (*str)++);
}
}
else
{
printf("/n/tno data");
}
PrintLine();
}
int main(void)
{
char *p = "hello";
char *q = p;
int i;
printf("/n/t*p = %s/n", p);
for (i = 1; i <= 5; i++)
{
PrintStrAndLine(p, i);
p = q;
}
}
此code在mingw2.05上输出,最后一项输出为错误值
*p = hello
*p++ = h
*p++ = e
*p++ = l
*p++ = l
*p++ = o
------------------------------
*(p++) = h
*(p++) = e
*(p++) = l
*(p++) = l
*(p++) = o
------------------------------
Terminated with return code -1073741819
Press any key to continue ...