研究以下小小
int main()
{
const int Max = 1;
int* p = &Max;
//const int i = 0;
//int* ip = &i;
int i = 0;
*p = 65;
// printf("%d%c %p \n", *p, *p, *p);
// *p = i;
while (i != 128)
{
// printf("%d\n",i);
*p = i;
printf("%d%c %p \n", *p, *p, *p);
i++;
}
// printf("%d%c %p \n", *p, *p, *p);
return 0;
} #include <stdio.h>
int main(){
int Max = 1; // <--------- 这里
int* p = &Max;
int i = 0;
*p = 65;
while (i != 128){
*p = i;
printf("%d%c %p \n", *p, *p, p); // <--------- 这里
i++;
}
return 0;
} #defineCHANGL_1 32
printf("%d\n", CHANGL_1);
printf("%c\n", CHANGL_1);
// printf("%f-=-%.2f\n", CHANGL_1, CHANGL_1);
//printf("%f-=-%1.9f\n", CHANGL_1, CHANGL_1);
printf("%p\n", CHANGL_1);
printf("%c\n", CHANGL_1+1);
int i;
i = 0;
while (i<(128-32))
{
printf("%c-=-%p\n", CHANGL_1 + i, CHANGL_1+i);
i++;
}
再找 怎么通过内存修改字符. char a[]="color 00"
我想通过内存++改变 字符'0'和'0'随机生成 十六进制的任意一个值. char r = "color 00";
char c[] = "0123456789abcdef";
//int str = strlen(c);
// printf("%d \n",str);
printf("%s\n",c);
printf("%p\n", c);
// printf("%p\n", *c+2);
//printf("%p\n", *c + 1);
unsigned int* ip = (unsigned int*)c;
printf("%p %p \n", ip, *ip);
ip = (unsigned int*)c+1;
printf("%p %p \n", ip, *ip);
ip = (unsigned int*)c+2;
printf("%p %p \n", ip, *ip);
ip = (unsigned int*)c + 3;
printf("%p %p \n", ip, *ip);
printf("===================\n");
ip = (unsigned int*)r;
printf("%p %p \n", ip, *ip);
ip = (unsigned int*)r+1;
printf("%p %p \n", ip, *ip);
*ip = 0x33323130;
printf("%s %p%p\n",r,*ip,ip);
//内存赋值 int main()
{
char a = "abccba";
char aa = { 1,2,3,3,2,1 };
char* p = (unsigned char*)&a;
char* pp = (unsigned char*)&aa;
printf("数组a的首地址:%p\n",p);
printf("数组a的首地址:%p\n", pp);
unsigned int i=0;
while (i < 6)
{
printf("数组a的首地址+%d 得出首地址下的偏移地址:%p\n",i, p+i);
printf("地址取值 %c\n", *(p + i));
printf("数组a的首地址+%d 得出首地址下的偏移地址:%p\n", i, pp + i);
printf("地址取值 %d\n", *(pp + i));
i++;
}
return 0;
}
//地址取值
页:
[1]