为什么包含iostream.h头文件下载的时候可以用iostream,而非要stdlib.h加.h?

C++中#include包含头文件带 .h 和不带 .h 的区别_百度文库
两大类热门资源免费畅读
续费一年阅读会员,立省24元!
C++中#include包含头文件带 .h 和不带 .h 的区别
上传于||文档简介
&&C​+​+​中​#​i​n​c​l​u​d​e​包​含​头​文​件​带​ ​.​h​ ​和​不​带​ ​.​h​ ​的​区​别
阅读已结束,如果下载本文需要使用0下载券
想免费下载更多文档?
你可能喜欢3712人阅读
STL学习(4)
#include &iostream&
#include &stdlib.h&
// Need random(), srandom()
#include &time.h&
// Need time()
#include &algorithm&
// Need sort(), copy()
#include &vector&
// Need vector
void Display(vector&int&& v, const char* s);
int main()
// Seed the random number generator
srandom( time(NULL) );
// Construct vector and fill with random integer values
vector&int& collection(10);
for (int i = 0; i & 10; i++)
collection[i] = random() % 10000;
// Display, sort, and redisplay
Display(collection, &Before sorting&);
sort(collection.begin(), collection.end());
Display(collection, &After sorting&);
// Display labels and contents of integer vector v
void Display(vector&int&& v, const char* s)
cout && endl && s &&
copy(v.begin(), v.end(),ostream_iterator&int&(cout, &\t&));
E:\workspace\test\3.cpp(14) : error C2065: 'srandom' : undeclared identifier
E:\workspace\test\3.cpp(19) : error C2065: 'random' : undeclared identifier
执行 cl.exe 时出错.
2.exe - 1 error(s), 0 warning(s)
原来:在linux下stdlib.h包含srandom 和random ,但在VC下stdlib.h包含的是srand和rand,所以应该改过来
#include &iostream&
#include &stdlib.h&
// Need random(), srandom()
#include &time.h&
// Need time()
#include &algorithm&
// Need sort(), copy()
#include &vector&
// Need vector
void Display(vector&int&& v, const char* s);
int main()
// Seed the random number generator
srand( time(NULL) );
srandom-----&srand
// Construct vector and fill with random integer values
vector&int& collection(10);
for (int i = 0; i & 10; i++)
collection[i] = rand() % 10000;
random-----&rand
// Display, sort, and redisplay
Display(collection, &Before sorting&);
sort(collection.begin(), collection.end());
Display(collection, &After sorting&);
// Display labels and contents of integer vector v
void Display(vector&int&& v, const char* s)
cout && endl && s &&
copy(v.begin(), v.end(),ostream_iterator&int&(cout, &\t&));
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
访问:329236次
积分:3743
积分:3743
排名:第5065名
原创:78篇
转载:93篇
评论:45条
(2)(2)(1)(5)(1)(3)(1)(6)(11)(21)(28)(18)(10)(9)(15)(25)(13)C++第五章习题解答_百度文库
两大类热门资源免费畅读
续费一年阅读会员,立省24元!
评价文档:
C++第五章习题解答
上传于||文档简介
&&同​济
大小:9.59KB
登录百度文库,专享文档复制特权,财富值每天免费拿!
你可能喜欢共有 964 人关注过本帖
标题:求问题答案#include &stdlib.h&
等 级:新手上路
&&问题点数:0&&回复次数:5&&&
求问题答案#include &stdlib.h&
搜索更多相关主题的帖子:
等 级:新手上路
我想问一下,这是什么意思,谢谢啊
来 自:湖北武汉
等 级:论坛游侠
帖 子:69
专家分:134
回复 2楼 佑铭vay
stdio.h是标准输入输出头文件。程序中调用的有关输入输出的函数原型大多数都在这个文件里;
stdlib.h是C/C++标准库文件之一,其中包括了大量的函数原型。当我们在程序中调用现成的库函数时,如果没有这些头文件的支持,编译器就无法知道程序中的函数名是什么东西。可以这样通俗地理解:就是说编译器在编译源程序时,要按照程序中调用时写出的函数名去到这些文件中找函数体……
等 级:论坛游民
帖 子:18
专家分:50
头文件包含啊,最基础的.如果函数出现在***.h中,那么就需要#include这个h文件
等 级:论坛游民
帖 子:42
专家分:44
#include &math.h&&&&&&这个头文件中包含的是一些数学函数,&&&比如&&&sin&&&&&cos&&&等;
#include&&&&stdlib.h&     这个头文件包含了一些比较杂类的库函数,比如&&&system&&&等,其他头文件中的函数类型很单一,但是这个头文件不是,混合了多种类型的函数集合。
这个问题,
如果有疑问,
可以打开这个&&&stdlib.h&&&看看有哪些函数就是了。
#include&&&&iostream.h&    //数据流输入/输出
#include&&&&math.h&      //定义数学函数
#include&&&&stdio.h&     &&&//定义输入/输出函数
#include&&&&stdlib.h&     //定义杂项函数及内存分配函数
#include&&&&string.h&     //字符串处理
引用别人的 昨天 刚好我也查了下 stdlib.h的作用
缺少stdlib.h提示 free malloc等有问题
缺少stdio.h提示 printf scanf等有问题
希望对你有帮助
等 级:新手上路
职位信息:某国最大互联网公司成都研发中心急寻高级测试工程师-测试leader(BASE地点:成都,因此,成都本地的GGJJ们看过来,如果您在北京,想要回成都工作,或是家乡为重庆、云南、贵州、湖北、湖南的GGJJ们,也可以到成都来工作。)如想要了解详细情况,QQ .也有其他研发类职位,windows C/C++ Linux C/C++ java类职位,欢迎为哪些想回成都的朋友引荐。
版权所有,并保留所有权利。
Powered by , Processed in 0.049973 second(s), 8 queries.
Copyright&, BCCN.NET, All Rights Reserved

我要回帖

更多关于 stdlib.h是什么头文件 的文章

 

随机推荐