1.break  永久终止循环,continue 结束当前循环

2。switch
每个case标签要有唯一值,(且为常量或常量表达式)
不加break 时执行流会贯穿整个case 标签
3 赋值操作符
char x;
int a;
a=x=y+3;
y+3 的值赋给a, a为char 类型或截断
a=x;可能会出现精度损失

#include <stdio.h>
#include<math.h>

void main()
{
int a,b,c;
char d;
printf("sizeof int %d\n",sizeof(int));
printf("szieof char %d\n",sizeof(char));
b=pow(2,5);
c=pow(2,5);
a=b*c;
printf("a=b*c %d,%d,%d \n",a,b,c);
d=b*c;
printf("d=b*c %d,%d,%d \n",d,b,c);
a=d=b*c;
printf("a=d=b*c %d,%d,%d \n",a,b,c);
}

char ch;
while((ch=getchar())!=EOF)
{
//EOF需要的位数比char 多,
//getchar()返回 int 类型,
ch=getchar()会截断
在不同的机器中循环会有不同的效果。
}


4 复合赋值语句
a=a+5,a+=5;
a[f(x)]=a[f(x)]+1;
a[f(x)]+=1;
#include <stdio.h>
#include<math.h>
int func()
{
static a=0;
printf("func run for %d time \n",a);
a++;
return a;
}
void main()
{
int i;
int b[4]={1,2,3,6};
b[func()]+=1;//b[1]_=1;func运行了一次
for(i=0;i<4;i++)
{
printf("%d  ",b[i]);
}
printf("\n");
b[func()]=b[func()]+1;//b[3=b[2]+1],func 运行了两次
for(i=0;i<4;i++)
{
printf("%d  ",b[i]);
}
printf("\n");
}



5.sizeof 
为单目操作符
sizeof( int )
sizeof(x)
int a[8];
szieof(a);
double a[8];
sizeof(a)

是以字节为单位的
int a=1;int b=1;
sizeof(a=b+1)//运行完后 a=1 ,不会进行运算

#include <stdio.h>
#include<math.h>

void main()
{
int a,d,e,f;
char b[4]={1,2,3,6};
double c[4]={1,2,3,4};
e=1;
f=0;
a=sizeof(b);
printf("sizeof b %d \n",a);

d=sizeof(c);
printf("sizeof c %d \n",d);
sizeof(f=e+1);
printf("f= %d\n",f);

}

指针的sizeof为 4 (32位软件中)

#include <stdio.h>
#include<math.h>

void main()
{
double (*fun)();
int a,d,e,g,x,y,z;
double *h;
double f;
char b[4]={1,2,3,6};
double c[3]={1,2,3};
double* (*s)[3][6]; 
e=1;
f=0;

h=c;

a=sizeof(b);//数组,返回数组所占的字节数 4*1=4
printf("sizeof b %d \n",a);

d=sizeof(c);//数组,返回数组所占的字节数 3*8=24
printf("sizeof c-> %d \n",d);
x=sizeof (h);//指针,即地址,32位软件中 地址为4字节
printf("sizeof h -> %d\n",x);
//h和c 比较

y=sizeof (*h);
printf("y= %d\n",y);//指针的元素,double 8字节

g=sizeof (fun);//指针,即地址,32位软件中 地址为4字节
printf("g= %d\n",g);

//double* (*s)[3][6]; 
//s为指针,指针指向2维数组,二维数组中存放的是指针
printf("s -> %d\n",sizeof(s));//指针 4
printf("*s -> %d\n",sizeof(*s));//整个数组 18个元素,每个元素为指针 3*6*4=72
printf("**s -> %d\n",sizeof(**s));//数组的一维 6个元素  6*4=24
printf("***s -> %d\n",sizeof(***s));//第一个元素,为指针 4
printf("****s -> %d\n",sizeof(****s));//指针所指的数,double 8

}

为什么:
d=sizeof(c);//数组,返回数组所占的字节数 3*8=24
printf("sizeof c-> %d \n",d);
x=sizeof (h);//指针,即地址,32位软件中 地址为4字节
printf("sizeof h -> %d\n",x);
//h和c 比较
为什么差别这么大。

数组名和指针的差别
它们的第一个区别是:数组名是指针常量,指针不能修改,指针指向的值可以改。
它们的第二个区别是:每当用到数组名这个指针的时候,系统都会传入数组的信息,而普通的指针只是一个4字节的整数。



6 if条件判断时 要注意 = 和 ==

7隐式类型转化
c的整型算数运算,至少的精度为 int
char a.b.c;
a=b*c;

先将 b c 的值转化为 int ,相乘后转化成 char (可能截断),赋值给 a
8算数转换
在操作数之间 将较低的类型转化成较高的类型
int a,b;
long c;
c=a*b;
根据优先级 先 a*b 为返回int 类型,c=a*b,将int 类型转化成 long 赋值给c
c=(long)a*b;
a 从 int转化成 long ,b和a两个操作数之间 a的类型比较高,b转化成long ,a*b 返回 long ,赋值给 c9


9 短路求值
&& || 具有短路求值特性

 

C函数及指针学习2的更多相关文章

  1. C函数及指针学习1

    1 大段程序注释的方法 #if 0#endif 2三字母词 以两个问号 开始的都要注意 3 字面值(常量) 在整型号字面值后加 字符L (long),U(unsigned)说明字符常量 为长整型 或( ...

  2. c 函数及指针学习 10

    标准库函数 1算数运算stdlib.h 2随机数stdlib.h 3字符串转化stdlib.h 4数学函数 math.h 5日期和时间 time.h 6信号 signal.h 7打印可变参数列表std ...

  3. c 函数及指针学习 9

    指针的高级应用 处理命令行参数 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 #include <stdio.h>   int main(int ar ...

  4. c 函数及指针学习 7

    1.结构的存储分配 1 2 printf("%d \n",sizeof(char)); printf("%d \n",sizeof(int)); int 类型为 ...

  5. c 函数及指针学习 5

    聚合数据类型 能够同时存储超过一个的单独数据. c语言提供了数组和结构体. 1. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 #include <stdio.h> # ...

  6. c 函数及指针学习 4

    1数组和指针声明的差别 声明数组:为数组分配内存,为数组名分配内存(指针常量 4个字节) 指针:为指针分配内存(指针变量 4个字节) 1 2 3 4 5 6 7 8 9 10 #include < ...

  7. c 函数及指针学习 3

    strlen(x) 返回 size_t 类型,size_t是 unsigned int 类型,所以 strlen(x)-strlen(y) 返回 unsigned int 始终 >=0 1 2 ...

  8. c 函数及指针学习 8

    联合体 1 2 3 4 5 6 7 8 9 10 11 12 13 #include <stdio.h>   union sa     {     double a;     int b; ...

  9. c 函数及指针学习 6

    不完整声明 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 /* 方法一   */ struct tag_a{ ...

随机推荐

  1. Cisco IOS Security command Guide

    copy system:running-config nvram:startup-config : to save your configuration changes to the startup ...

  2. Java基础毕向东day04

    1. 数组 2.选择排序.冒泡排序.折半查找.

  3. python黑帽子源码

    https://www.nostarch.com/download/BHP-Code.zip https://yunpan.cn/cPvLPWMTdWJRu  访问密码 4243

  4. windows-ubuntu环境变量的设置格式的不同

    1  在Ubuntu下输出环境变量,比如JAVA_HOME, 使用cat或者echo $JAVA_HOME即可,但是在windows下不可以, windows不支持cat命令,只能使用echo %JA ...

  5. UIkit框架之UIimageview

    1.继承链:UIview:UIresponder:NSObject 2.如果你想利用这个类来制作动态图片,你需要遵守以下的原则: (1)所有的图片的大小都要一样 (2)所有的图片要使用同样的比例,同样 ...

  6. php大力力 [036节] 后台系统的登录页面界面做完啦

    php大力力 [036节] 后台系统的登录页面界面做完啦 我认为做的不错,我就先不上截图啦 要你的祝福 分布注册 Twitter Login Or Signup Form 藤藤每日一练——172个Ic ...

  7. Linux下控制器IO地址

    在Linux下使用cat /proc/ioports可以查看控制器使用的IO地址范围

  8. Intellij导入外部的jar

    File -> Project Structure (ctrl + shift + alt + s ) -> Module -> Dependencies -> Add... ...

  9. Planning for a period of time

    After a period of struggle , i decided to follow the teacher Chen learning . Say true i really disli ...

  10. 修改主机名Ubuntu

    主机名存放在/etc/hostname 修改保存即可