C 画画内存图
程序员文章站
2022-06-03 22:47:16
...
//-------------------------1------
int a = 1;
void f(int b)
{
int c = 2;
c++;
static int d = 1;
d++;
a += b + c + d;
} int e = 3;
void main()
{ int p[] = {a,e,a+e};
char* q = "abcdef";
char w[10] = "123xyz";
strcpy(w+2,q+1);
p[0] = a;
f(4);
p[1] = a*2;
strcpy(w,"hello");
f(5);
p[2] = a * 3;
}
//--------------2-------------------
void main()
{
char* p = (char*)malloc(10);
*(p+1) = "abcdef"[2];
strcpy(p,"xyz");
int x = 1;
int y = 2;
strcpy(p+3,"QWERTY"+x+y);
char* q = p;
char z[] = {p[0],p[1],p[4]};
free(q);
p = z;
q = p + 4;
*q = 'W';
}
//--------------3-------------------
void main(){
char* arr[3]={"123","abcdef","hh"};
char* p = arr[0];
cout<< p << *p;
char* q = p + 1;
cout<< q << *q;
q = arr[1];
cout<< q << *q;
}
//--------------4-------------------
int* p;
void main()
{
p = (int*)malloc(16);
for (int i = 0;i < 4; ++i)
p[i] = i*10+1;
int x[] = {p[0],p[2],p[1]+p[3]};
int* q = p;
q += 1;
*q = 5;
q += 1;
*q = 10;
free(q-2);
p = x+1;
q = p+1;
*x = *p * *q;
}
//------------------5---------------
void main(){
short arr[3][2]={1,2,3,4,5,6};
arr[0][0] = arr[0][1];
short* p = arr[0];
short* q = arr[1];
int d = p[0] + q[2];
}
//----------------6------------------
void f(int* p)
{
p = (int*)malloc(8);
*p = 100;
*(p+1) = 200;
}
void main(){
int* q = 0;
f(q);
}
//----------------7-----------------
void f(int*& p)
{
p = (int*)malloc(8);
*p = 100;
*(p+1) = 200;
}
void main(){
int* q = 0;
f(q);
}
//----------------8-----------------
void f(int** p)
{
*p = (int*)malloc(8);
**p = 100;
*(*p+1) = 200;
}
void main(){
int* q = 0;
f(&q);
}
欢迎探讨,有参考答案