您的位置:首页 > 编程语言 > C语言/C++

C/C++ 函数所在的头文件(二)

2016-02-20 08:47 337 查看
C++基础::函数、类、类型所在的头文件 && 便捷函数 && 接口的介绍

C 头文件

stuffheader说明
malloc<stdlib.h>
exit<cstdlib.h>
strlen<string.h><string>也给出了该函数的实现
自然无需在std的命名空间中
typeid<typeinfo>但不在
std
标准命名空间中
getch()/_getch()<conio.h>Console Input/Output(控制台输入输出)的简写

C++ 头文件

stuffheader说明
min/maxalgorithmstd

cstdlib ⇒ exit()

void exit(int code);


错误码主要有:

#define EXIT_SUCCESS    0
#define EXIT_FAILURE    1


std::ifstream ifs(filename);
if (!ifs.good())
{
std::cerr << "cannot open the input file \"" << filename << "\"" << std::endl;
exit(EXIT_FAILURE);
}


typeid

int fputs(const char*, FILE* );


为什么可将标准输入输出(stdin/stdout)赋值给
fputs
的第二个参数,可见stdin/stdout的真实数据类型应是
FILE*
,使用
typeid
一试便知:

printf("%s\n", typeid(stdout).name());
printf("%s\n", typeid(FILE*).name());


toupper/tolower

所在的头文件 :

#include <ctype.h>      // C
#include <cctype>       // C++


函数声明:

int toupper(int c);


使用:

char(toupper('a'))  ⇒ 'A'
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: