#include<stdio.h>
#include<string.h>
void CopyPointer(char *a)
{
char *tmp = (char *) strdup(a);
printf(" a = %s\n",a);
printf(" tmp = %s\n",tmp);
printf(" tmp = %s\n",tmp+1);
}
int main()
{
char a[] = "happy";
CopyPointer(a);
printf(" a %s\n",a);
}
Result
a = happy
tmp = happy
tmp = appy
a happy
Reference:
0 意見:
張貼留言