向null地址copy数据和不断改变指针指向

时间:2022-11-30 10:24:20
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<stdlib.h>
#include<string.h> int main11()
{ system("pause");
return ;
} void main22()
{
char *p1 = NULL;
p1 = 0x00077;
strcpy(p1, "");
system("pause");
return ;
} void main()
{
char buf[];
int i;
int j = ; char *p1 = NULL;//c可以在栈上分配内存
char *p2 = NULL;
p1 = &buf[]; //不断的改变p1的值 相当于不断的改变指针的指向。
p1 = &buf[];
p1 = &buf[]; for ( i = ; i < ;i++)
{
p1 = &buf[i];
} p2 = (char *)malloc();
strcpy(p2,"abdafgadf121313");
for ( i = ; i < ; i++)
{
p1 = p2 + i;
printf("%c ", *p1);
}
printf("hello....\n");
system("pause");
return;
}