#define _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>
#include <string.h>
struct stu
{
char name[20];
int age;
char id[20];
};
int main()
{
int a = 0;
struct stu s1 = { "张三", 20, "775513640" };
struct stu* ps = &s1;
printf("%s\n", ps->name);
printf("%d\n", ps->age);
/*printf("%s\n", (*ps).name);
printf("%d\n", (*ps).age);*/
return 0;
}
int main()
{
char a = 3;
//00000000000000000000000000000011
//00000011 -- a
char b = 127;
//00000000000000000000000001111111
//01111111 -- b
char c = a + b;
//a+b
//00000011 -- a
//01111111 -- b
//10000010 -- c
printf("%d\n", c);
return 0;
}
int main()
{
int a = 10;
int b = 20;
int c = a + a * 3;
return 0;
}
int main()
{
int a = 0x11223344;
int* pa = &a;
//*pa = 0;
char* pc = &a;
//指针类型决定了指针进行解引用操作的时候,能够访问空间的大小
//int*p; *p能够访问4个字节
//char*p; *p能够访问1个字节
//double*p; *p能够访问8个字节
//*pc = 0;
/*指针类型决定了:指针一步走多远(指针的步长)
int *p; p+1-->4
char *p; p+1-->1
double*p; p+1-->8
*/
printf("%p\n", pa);
printf("%p\n", pa+1);
printf("%p\n", pc);
printf("%p\n", pc+1);
return 0;
}
int main()
{
int arr[10] = { 0 };
char* p = &arr;
int i = 0;
for (i = 0; i < 10; i++)
{
*(p + i) = 1;
}
return 0;
}
int mian()
{
//int a;//局部变量不初始化,默认是随机值
int*p;//局部的指针变量,就被初始化随机值
*p = 20;
return 0;
}
int main()
{
int arr[10] = { 0 };
int *p = arr;
int i = 0;
for (i = 0; i < 12; i++)
{
p++;
}
return 0;
}
test()
{
int a = 10;
return &a;
}
int main()
{
int *p = test();
*p = 20;
return 0;
}
int main()
{
int* p;
*p = 20;
return 0;
}
int main()
{
int a[10] = { 0 };
int i = 0;
int* p = a;
for (i = 0; i <= 12; i++)
{
//*p = 1;
//p++;
*p++ = i;
}
return 0;
}
int* test()
{
/*int a = 10;
return &a;*/
int arr[10] = { 0 };
}
int main()
{
int *p = test();
printf("%d\n", *p);
return 0;
}
int main()
{
int a = 10;
int *pa = &a;
*pa = 20;
//int* p = NULL;//NULL-- ((void *)0)用来初始化指针,给指针赋值
*pa = 10;
pa = NULL;
if (pa != NULL)
{
*pa = 20;
}
return 0;
}
int main()
{
int arr[10] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
int i = 0;
int sz = sizeof arr / sizeof (arr[0]);
int* p = &arr[9];
/*for (i = 0; i < sz; i++)
{
printf("%d", *p);
p++;
}*/
for (i = 0; i < 5; i++)
{
printf("%d ", *p);
p -= 2;
}
return 0;
}
标签:return,16,--,char,int,printf,main,指针
From: https://blog.51cto.com/u_16182079/6739910