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. xml装php数组

    $data = simplexml_load_string($res, 'SimpleXMLElement', LIBXML_NOCDATA); $arr = converArray($data); ...

  2. 创建条形码图像易用的控制字符编码功能的条形码控件Native Crystal Reports Barcode Generator

    Native Crystal Reports Barcode Generator是一个对象,它可以很容易地被嵌入到一个Crystal Report中用于创建条形码图像.一旦此条形码被安装在一个报表中, ...

  3. linux的简单网络配置

    1,修改IP edit file: # if rh family system /etc/sysconfig/network-scripts/ifcfg-eth0 (eth0可能会是别的名字) # i ...

  4. Maven 建立web项目 The import javax.servlet cannot be resolved

    右击项目,选择Java Build Path->Libraries->Add External JARs,tomcat的路径lib文件夹下选中"servlet-api.jar&q ...

  5. C# HttpBrowser 跨进程访问,解决内存泄露问题

    #undef DEBUG using Microsoft.Win32; using Newtonsoft.Json; using System; using System.Collections.Ge ...

  6. java基础-008

     57.面向对象软件开发的优点 代码开发模块化,更易于维护 代码复用 增强代码的可靠性和灵活性 增强代码的可理解性 面向对象编程有很多重要的特性,比如:封装,继承,多态和抽象  58.封装 封装给对象 ...

  7. 《Java程序性能优化:让你的Java程序更快、更稳定》

    Java程序性能优化:让你的Java程序更快.更稳定, 卓越网更便宜,不错的书吧

  8. poj1141 区间dp+路径

    //Accepted 176 KB 47 ms //感谢大神们为我们这群渣渣铺平前进的道路!! //用scanf("%s",s)!=EOF WA到死 #include <cs ...

  9. kali linux karmetasploit配置

    原理分析:http://www.freebuf.com/articles/77055.html 转官方说明:https://www.offensive-security.com/metasploit- ...

  10. 技术分享:逆向海盗船k95机械键盘

    引文 在几年前我买了一个海盗船 K95 Vengeance机械键盘,键盘有上有背光功能,于是我在考虑是不是可以修改一下.但作者表示购买来的键盘上面没有很多的资料可供利用,需要注意的是,新版的K95与旧 ...