目录
一般写法
自动生成
输入
运行结果
参考链接
一般写法
例如这样有一根file.h头文件,一般写法如下
//file.h
//条件编译
#ifndef _FILE_H_//如果没有引入头文件file.h
#define _FILE_H_//那就引入头文件file.h
//结构体和函数声明....
//1 根据跟文件路径和模式获取文件指针
FILE* getFILE(char* filePath,char* mode);
//2 使用临时文件替换原文件
void updateOldFileByNew(char*oldFileName,char*newFileName);
#endif
自动生成
当然,手动写还是有点麻烦,所以我写了点js代码来自动生成:
变成大写{
var input=document.getElementById("output");
input.value=input.value.toUpperCase();//变成大写
}
function cyuyantouwenjianshengming()
{
//User.h
// #ifndef _USER_H_ //如果没有引入头文件User.h
// #define _USER_H_ //那就引入头文件User.h
// #endif
var input=document.getElementById("output");
var oldValue=input.value;//保存原来的值
var daxie=input.value.toUpperCase();//变成大写
input.value="//"+oldValue+".h\n"+
"#ifndef _"+daxie+"_H_ //如果没有引入头文件"+oldValue+".h\n"+
" #define _"+daxie+"_H_ //那就引入头文件"+oldValue+".h\n"+
"#endif";
}
输入
例如我要生成file.h的头文件代码,则输入文件名file,然后点击生成c语言头文件声明:
运行结果
//file.h
#ifndef _FILE_H_//如果没有引入头文件file.h
#define _FILE_H_//那就引入头文件file.h
#endif
然后把代码粘贴到头文件file.h中即可。
参考链接
https://blog..net/Com_ma/article/details/78546807
https://blog..net/K346K346/article/details/48877773
https://blog..net/wr132/article/details/65635003
https://blog..net/abc_12366/article/details/79155540
https://blog..net/wr132/article/details/65635003
https://blog..net/wandermen/article/details/9254919
https://blog..net/xhbxhbsq/article/details/78955216
本文链接: C语言头文件正确写法