#define _CRT_SECURE_NO_WARNINGS//强行去掉安全检查
#include<stdio.h>
#include<stdlib.h>
#include<Windows.h>
void main()
{
char *p = NULL;
char *q = NULL;
char buf[100] = "chenqi-----777";
p = &buf[0];
printf("p1=%d,%c\n",p ,*p);
p = &buf[1];
printf("p2=%d,%c\n\n", p, *p);
for (int i = 0; i < strlen(buf); i++)
{
p = &buf[i];
//p=buf+i;
printf("所有=%d,%c\n", p, *p);
}
q = (char *)malloc(100);
if (q == NULL)
{
return -1;
}
strcpy(q, "abcdefg");
printf("\n\n");
for (int i = 0; i < strlen(q); i++)
{
p = q + i;
//改变指针赋值知识点
printf("%c", *p);
}
system("pause");
}
#include<stdio.h>
#include<stdlib.h>
#include<Windows.h>
void main()
{
char *p = NULL;
char *q = NULL;
char buf[100] = "chenqi-----777";
p = &buf[0];
printf("p1=%d,%c\n",p ,*p);
p = &buf[1];
printf("p2=%d,%c\n\n", p, *p);
for (int i = 0; i < strlen(buf); i++)
{
p = &buf[i];
//p=buf+i;
printf("所有=%d,%c\n", p, *p);
}
q = (char *)malloc(100);
if (q == NULL)
{
return -1;
}
strcpy(q, "abcdefg");
printf("\n\n");
for (int i = 0; i < strlen(q); i++)
{
p = q + i;
//改变指针赋值知识点
printf("%c", *p);
}
system("pause");
}