2016—4—25
#include"string.h"
				
				strlwr()把字符串中大写换成小写
				
				strupr()把字符串中小写换成大写
				
				| 
									 #include"stdio.h"
										 
										#include"string.h"
										 
										#include"stdlib.h"
										 
										int main()
										 
										{
										 
										        char a1[]="Hello World";
										 
										        char a2[]="yun nan";
										 
										        char *b1=strlwr(a1);
										 
										        char *b2=strupr(a2);
										 
										        printf("%s\n",b1);
										 
										        printf("%s\n",b2);
										 
										        system("pause");
										 
										}
										 
									 | 
								
2016—4—26
				
				\r   换行,会到本行开头(Home)
				
			\b   退格,光标后退一格
				
				C语言只有字符串变量,没有常量
				
				2016—4—27
				
				float 有效位6-7位
					
					double  15-16
					
					long double  18-19
					
					long long  8个字节
					
					vs (ctrl+k,ctrl+f)可以自动控制代码格式对齐
					
					~按位取反
					
					^按位异或    1010       &按位与    1010
					
					                      0111                        0111
					
					             ------------                 ------------
					
					                      1101                        0010
					
					计算机中数都是按补码存放的,正数的二进制就是原码,反码和补码全都相同;负数的原码是二进制表示,反码为原码最高位不变其余各位取反、补码为反码+1;
					
					| 
										 #include <iostream>
										 
										using namespace std;
										 
										int main()
										 
										{
										 
										   int a=4,b=3;
										 
										   cout<<"~a="<<~a<<"   ~b"<<~b<<endl;
										 
										   cout<<"a^b="<<(a^b)<<endl;
										 
										   cout<<"a&b="<<(a&b)<<endl;
										 
										   system("pause");
										 
										  return 0;
										 
										}
										 
									 | 
									4-------0000 0100 ~-------1111 1011 负数,计算机中存的是补码 反码---- 1000 0100 补码-----1000 0101 -5 ------------------------------------------------------------------- 计算机中都是按补码运算的,int a = -11 ; ~a = 10 ; 1、a 在计算机中是按补码存放的---> 1000 1011 ==》1111 0101 2、进行取反操作---> 1111 0101 ==》0000 1010 就是十进制的 10  | 
								
短路运算|
					
					短路运算符就是我们常用的“&&”、“||”,一般称为“条件操作”。
					
					If(a>b||printf(“a小于b”))
					
					 如果a>b就运行下面,否则输出printf;
					
					| 
										 #include"stdio.h"
											 
											#include"stdlib.h"
											 
											int main()
											 
											{
											 
											        int a=10,b=3;
											 
											        if(a>b||printf("a<b\n"));
											 
											        if(a<b||printf("a>b\n"));
											 
											        system("pause");
											 
											}
											 
										 | 
									
2016—4—28
				
			| 
								 #include"stdio.h"
								 
								#include"stdlib.h"
								 
								#include"setjmp.h"
								 
								jmp_buf envbuf;  //定义变量
								 
								int ret;
								 
								void sum()
								 
								{
								 
								        printf("ret is %d\n",ret);
								 
								        printf("I am sum\n");
								 
								        longjmp(envbuf,1);
								 
								        printf("I am not here\n");
								 
								}
								 
								 | 
							
								 int main()
								 
								{
								 
								        ret=setjmp(envbuf);  
								 
								//跳转函数,ret=0;跳转后longjmp的第二个参数就为setjmp的返回值
								 
								        if(0==ret)
								 
								        {  sum();  }
								 
								        printf("ret is %d\n",ret);
								 
								        system("pause");
								 
								}
								  | 
						
2016—4—29
			
			char *strncpy( char *to, const char *from, size_t count );
			
			//将字符串from 中至多count个字符复制到字符串to中。如果字符串from 的长度小于count,其余部分用'\0'填补。返回处理完成的字符串。会覆盖
				
				char *strncat( char *to, const char *from, size_t count );
				//将字符串from 
中至多count个字符连接到字符串to中,追加空值结束符。返回处理完成的字符串。
				
				int strncmp( const char *str1, const char *str2, size_t count );
				
				//比较字符串str1 和 str2中至多count个字符。str1比str2少,返回小于0的数;str1等于str2,返回0;str1大于str2,返回大于0的数 。
				
				eg:strncpy(str1,str2,count)    strncat(str1,str2,count)    strncmp(str1,str2,count)
				
				void *memset( void *buffer, int ch, size_t count );
					//函数拷贝ch 到buffer 从头开始的count 个字符里, 并返回buffer指针。 
memset() 可以应用在将一段内存初始化为某个值。
				memset(str(int),'\0'(0),sizeof(int))   //字符串(整形)数组置0,不要置成其他字符
				
				void *memcpy( void *to, const void *from, size_t count );
				
				//函数从from中复制count 个字符到to中,并返回to指针。 
如果to 和 from 重叠,则函数行为不确定,复制从第一个开始,会产生覆盖。
				
				eg:  memcpy(str1(int),str2(int),size)         int a[10],int b[10]={1,2,……},memcpy(a,b,sizeof(b))   ->   a[10]={1,2,……};结构体拷贝
				
				int memcmp( const void *buffer1, const void *buffer2, size_t count );
				
				//函数比较buffer1 和 buffer2的前count 个字符
				
				eg:memcmp(int,int,size)(这个只能比较内存(整形、浮点型之类)的)
				
				void *memmove( void *to, const void *from, size_t count );
				//与mencpy相同,不同的是当to 和 from 重叠,函数正常仍能工作。
				
				eg:memmove(str1,str2,size)  自己往自己身上拷贝  abcde->deabc
				
				全局变量   int a;  外部文件引用extern int a;      //比如我的.c文件里有定义全局变量,头文件里要用,可以直接extern引入。
				
				全局变量   int a;  想要只能自己文件引用  其他文件不能引用,static int a;
				
				定义好一个局部变量的字符数组最好要把它初始化为空--》char sstr[10]="";  或者char sstr[10]={};
				
			main函数中的 argv[0] 表示的是 .exe 文件
			
			
                    
                
                
            
        
浙公网安备 33010602011771号