如何包括基本的头文件这可与UNIX下的C? [英] How to include the basic header files which are available with C in UNIX?

查看:140
本文介绍了如何包括基本的头文件这可与UNIX下的C?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我们在Turbo C的工作,我们得到了所有的功能和头文件在默认情况下,我们可以通过一般包括
    #inlcude
例如:文件stdlib.h,math.h中

When we work on Turbo C, we get all the functions and header files by default which we can include normally by #inlcude eg: stdlib.h, math.h

但是,撰写使用这样的头文件我得到的错误,因为我无法包含这些文件的简单程序时。难道这头文件默认提供给我们使用?
如果是的话那么如何使用这些头文件?
当我在math.h中使用的函数sqrt我越来越误差没有得到包括math.h中,所以我不得不把它列入下面的命令:

But when writing a simple program using such header files I am getting error because I'm unable to include these files. Aren't these header files available by default for us to use? If yes then how to use such header files? When I used a function sqrt in "math.h" I was getting error as math.h was not getting included so I had to include it in the following command:

cc -c aaa.c -I/usr/local/ssl/include
gcc -o aaa aaa.c -I/usr/local/ssl/include -L/usr/local/ssl/lib -lcrypto -lm
./aaa

在此命令:第二个是有 -lm 末包括math.h中

In this command the 2nd one is having -lm at the end to include math.h

再同样地,我使用的功能itoa()这是在的 stdlib.h中
其中我执行UNIX在Solaris服务器上,但没有得到包括它,我gettig错误。现在我不知道如何添加这个头文件。

again similarly I used a function itoa() which is in stdlib.h which I am executing on a UNIX Solaris server, but it is not getting included and I am gettig error. Now I don't know how to add this header file.

推荐答案

文件math.h 头通常包括在内。在code可以编译。然而,编译器将找不到编译的二进制文件(文件math.h实施)为链接以除非指定它这样做。所以,你必须在命令中指定-lm。

The math.h header is included normally. The code can compile. However, the compiler won't find the compiled binary (the implementation of math.h) to link to unless you specify it to do so. So you have to specify -lm in the command.

itoa()不是文件stdlib.h 一个标准功能,所以不要使用它。你可以用sprintf来代替。

itoa() is not a standard function in stdlib.h, so do not use it. You can use sprintf instead.

这篇关于如何包括基本的头文件这可与UNIX下的C?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆