C标准中一些预定义的宏
__DATE__
进行预处理的日期(“Mmm dd yyyy”形式的字符串文字)
__FILE__
代表当前源代码文件名的字符串文字
__LINE__
代表当前源代码中的行号的整数常量
__TIME__
源文件编译时间,格式微“hh:mm:ss”
__func__
当前所在函数名
下面一个例子是打印上面这些预定义的宏的。
#include <stdio.h>
#include <stdlib.h>
void why_me();
int main()
{
printf( "The file is %s.\n", __FILE__ );
printf( "The date is %s.\n", __DATE__ );
printf( "The time is %s.\n", __TIME__ );
printf( "This is line %d.\n", __LINE__ );
printf( "This function is %s.\n", __func__ );
why_me();
return 0;
}
void why_me()
{
printf( "This function is %s\n", __func__ );
printf( "The file is %s.\n", __FILE__ );
printf( "This is line %d.\n", __LINE__ );
}
相关文档:
一般变量定义在*.c文件中,而*.h文件中声明变量或函数名和符号名.
避面重复编译的解决方法:
比如你有两个C文件,这两个C文件都include了同一个头文件。而编译时,这两个C文件都要调用同一个头文件去编译,重复编译会产生大量的声明冲突。解决这个问题的方法使用#ifndef, #endif, #endif。
&nbs ......
1.fopen()
fopen的原型是:FILE *fopen(const char *filename,const char *mode),fopen实现三个功能
为使用而打开一个流
把一个文件和此流相连接
给此流返回一个FILE指针
参数filename指向要打开的文件名,mode表示打开状态的字符串,其取值如下表
字符串 含义
"r" 以只读方式打开文件 ......
以下摘自《edyang 语录》:
记住一个人,最重要的是记住他/她/它是男人/女人/东东,有没有贬过,有没有吻过,有没有咬过,名字记不住反而关紧要。
C Runtime Library
大家在学过C++之后,可能对C Runtime Library这个名字有一定的误会,可能认为是运行时库是动态链接的,其实不然,想想C语言其实没有 ......
这个本来以前也写过的,今天无聊复习下 再写一遍。简单的一塌糊涂,写的不咋地大家见谅哦!有空再加强 嘿嘿!
#include <stdio.h>
#include <stdlib.h>
#include <sys/socket.h>
#include <time.h>
#include <sys/types.h>
#include <netinet/in.h>
#include <netdb.h ......