![](https://img-blog.csdnimg.cn/20201014180756928.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
C
秀天人
这个作者很懒,什么都没留下…
展开
-
函数缺省是external
Test.cpp#include //using namespace std;int func();int main(){ printf("%d",func());}test1.cppint func(){ return 1;}原创 2013-11-21 14:19:56 · 679 阅读 · 0 评论 -
matrix[2][10]声明
#include void func1(int mat[][10]){}void func2(int (*mat)[10]){}int main(){ int matrix[2][10]; func1(matrix); func2(matrix);}原创 2013-11-24 14:32:14 · 475 阅读 · 0 评论 -
strlen返回类型size_t
#include #include int main(){ char* s="abcdefghijklmnopqrstuvwxyz"; if(strlen(s)-100>=0){ printf("ss"); }} 输出ss原创 2013-11-24 14:37:51 · 794 阅读 · 0 评论 -
strchr
#include #include int main(){ const char string[20]="Hello there,honey."; const char* ans; ans=strchr(string,'h'); printf("%d",ans-string);} 输出:7原创 2013-11-24 14:52:04 · 399 阅读 · 0 评论 -
结构体存储分配
#include int main(){ struct ALIGN1 { int b; char a; char c; }; struct ALIGN2 { char a; int b; char c; }; printf("%d ,%d",sizeof ALIGN1,sizeof ALIGN2);} 输出:8 ,1原创 2013-11-24 15:05:05 · 414 阅读 · 0 评论 -
calloc
#include #include int main(){ int * p; p = (int*) calloc (8,sizeof(int)); //sizeof()要有括号 printf("%d",p[7]);}原创 2013-11-24 15:21:19 · 457 阅读 · 0 评论 -
字符串常量
#include int main(){ printf("%c,",*("xyz"+2)); printf("%c","xyz"[2]);}原创 2013-11-24 15:24:30 · 377 阅读 · 0 评论 -
#ifdef
#include #define TEST_H#ifdef TEST_Hint main(){ printf("%c,",*("xyz"+2)); printf("%c","xyz"[2]);}#endif原创 2013-11-24 15:34:05 · 404 阅读 · 0 评论 -
fgetc;getc
#include int main(){ FILE* f1=fopen("a.txt","r"); if(f1==NULL){ perror("Error opening file"); } int a=fgetc(f1); int b=getc(f1); printf("%c,%c",a,b);}原创 2013-11-24 15:49:37 · 461 阅读 · 0 评论 -
ungetc()
#include int main(){ FILE* f1=fopen("a.txt","r"); char buf[256]; if(f1==NULL){ perror("Error opening file"); } while(!feof(f1)){ int a=getc(f1); if(a='1'){ ungetc('2',f1);原创 2013-11-24 16:08:32 · 732 阅读 · 0 评论 -
union
#include int main(){ union{ int a; float b; char c[4]; }x; x.b=1.0; printf("%d,%f,%s",x.a,x.b,x.c);} 输出:1065363216,1.000000,原创 2013-11-24 15:11:13 · 439 阅读 · 0 评论 -
获得当前时间
#include #include int main(){ time_t timer; time(&timer); struct tm* timeinfo=localtime(&timer); printf("%s",asctime(timeinfo));}原创 2013-11-24 16:20:03 · 408 阅读 · 0 评论 -
多个.h和.c文件的使用
func.h#ifndef FUNC_H#define FUNC_Hint f();#endif func.c#include "func.h"int f(){ return 1;} Test.c#include #include "func.h"int main(){ int i=f(); printf("%d",i);}原创 2013-11-26 14:25:37 · 518 阅读 · 0 评论 -
volatile
volatile关键字是一种类型修饰符,用它声明的类型变量表示可以被某些编译器未知的因素更改,比如:操作系统、硬件或者其它线程等。遇到这个关键字声明的变量,编译器对访问该变量的代码就不再进行优化,从而可以提供对特殊地址的稳定访问。release模式下,编译器对代码进行了优化.一般说来,volatile用在如下的几个地方:1、中断服务程序中修改的供其它程序检测的变量需要加volati转载 2013-12-14 10:39:17 · 554 阅读 · 0 评论 -
typedef用法总结
用途一:定义一种类型的别名,而不只是简单的宏替换。可以用作同时声明指针型的多个对象。比如:char* pa, pb; // 这多数不符合我们的意图,它只声明了一个指向字符变量的指针,// 和一个字符变量;以下则可行:typedef char* PCHAR; PCHAR pa, pb; 这种用法很有用,特别是char* pa, pb的定义,初学者往往认为是定义了两个字符转载 2013-12-22 09:33:13 · 411 阅读 · 0 评论 -
使用可变参数;不能用float 截断
#include #include float average(int n_value, ...){ double sum=0.0; va_list v1; va_start(v1,n_value); for(int i=0;i// double f1=va_arg(v1,double);// printf("%f ,",f1);// sum+=f1原创 2013-11-24 11:42:49 · 411 阅读 · 0 评论 -
strspn
#include #include int main(){ int i; char strtext[] = "129th34"; char cset[] = "1234567890"; i = strspn (strtext,cset); printf ("The initial number has %d digits.\n",i); return 0;}原创 2013-11-24 15:00:38 · 352 阅读 · 0 评论 -
true=1
#include //using namespace std;int main(){ printf("%d",true);}C不具备bool值原创 2013-11-21 14:52:20 · 631 阅读 · 0 评论 -
else从属于最靠近它的不完整的if语句
#include int main(){ if(i>1) if(j>2) printf("i>1 and j>2\n"); else printf("no they are not\n"); }原创 2013-11-21 14:58:42 · 736 阅读 · 0 评论 -
函数形参作用域为整个函数体
#include using namespace std;int func(int i){ int i; // 形参“i”的重定义 i=1; return i;}int main(){ int a=func(2); printf("%d",a);}原创 2013-11-21 11:28:08 · 1573 阅读 · 0 评论 -
原型作用域内不能重名
#include using namespace std;int func(int i,float i){ //! “i”: 重定义;不同的基类型 i=1; return i;}int main(){ int a=func(2,2.0); //!“func”: 函数不接受 2 个参数 printf("%d",a);} int func(in原创 2013-11-21 13:32:22 · 536 阅读 · 0 评论 -
字符串常量不能修改
#include using namespace std;int main(){ char* b="Line 1\nLine2\n";// *b='l'; //报错 char c[20]="Line 1\nLine2\n"; c[0]='l'; printf("%s",c); printf("%s",b);}原创 2013-11-21 11:15:15 · 792 阅读 · 0 评论 -
产生随机数
#include #include #include int main(){ srand(time(NULL)); for(int i=0;i printf("%d ",rand()); } }原创 2013-11-23 21:00:41 · 432 阅读 · 0 评论 -
++a可以为左值,VS2010
#include int main(){ int a=10; ++a=1; printf("%d",a);} a=1原创 2013-11-23 21:17:49 · 496 阅读 · 0 评论 -
隐式类型转换
#include int main(){ char a='a'; char b='b'; char c=a+b;}b,c被提升为整形原创 2013-11-23 21:25:40 · 401 阅读 · 0 评论 -
x+y+1溢出地点不同
#include #include int main(){ signed int x=pow(2.0,31)-1; signed int y=pow(2.0,31)-1; printf("%d\n",x+y+1); printf("%d",y+1);} -1-2147483648原创 2013-11-23 21:33:11 · 551 阅读 · 1 评论 -
&a[100]可以使用
#include int main(){ int a[100]; int* vp; for(vp=&a[0];vp *vp++=0; } for(vp=&a[0];vp printf("%d",*vp); vp++; }}原创 2013-11-23 21:39:51 · 411 阅读 · 0 评论 -
“f”: 不是一个函数。不提示返回值为int
#include f(){}int main(){ float f=f();}原创 2013-11-23 21:51:45 · 469 阅读 · 0 评论 -
strcpy_s复制之后的字符被丢失
#include #include int main(){ char message[]="Original message"; strcpy(message,"different"); printf("%s",message); printf("%c",message[12]); }输出:different sstrcpy_s(message,"differ原创 2013-11-24 14:45:54 · 830 阅读 · 0 评论 -
#if
#include #if 1!=1int main(){ printf("%c,",*("xyz"+1)); printf("%c","xyz"[1]);}#elif 1==1int main(){ printf("%c,",*("xyz"+2)); printf("%c","xyz"[2]);}#endif原创 2013-11-24 15:29:49 · 390 阅读 · 0 评论 -
*(*(matrix+1)+1)=matrix[1][1]
#include int main(){ int matrix[2][2]={1,2,3,0}; printf("%d",*(*(matrix+1)+1));}原创 2013-11-24 14:26:48 · 598 阅读 · 0 评论 -
CRC循环校验码c语言实现
http://forum.eepw.com.cn/thread/207575/1转载 2014-03-18 19:28:24 · 1072 阅读 · 0 评论