首页 > 试题广场 >

引用标准库,下面的说法哪些是正确的?

[单选题]
引用标准库,下面的说法哪些是正确的?
  • 语句#include "stdio. h" 是正确的,而且程序编译的速度比#include<stdio. h>要快
  • 语句#include <stdio. h>是正确的,而且程序编译的速度比#include"stdio. h"要快
  • 语句#include "stdio. h"和#include <stdio. h>都是正确的,程序编译速度没有区别
  • 语句#include "stdio. h"是错误的
推荐
B
注释:include   ""是先从本地目录开始寻找,然后去寻找系统路径,而Include   <>   相反先从系统目录,后从本地目录,
 
编辑于 2015-01-12 21:38:09 回复(6)
首先看看外国人怎么说的:
What is the difference between #include <file> and #include “file”?
When writing your C program, you can include files in two ways. The first way is to surround the file you want to include with the angled brackets < and >. This method of inclusion tells the preprocessor to look for the file in the predefined default location. This predefined default location is often an INCLUDE environment variable that denotes the path to your include files. For instance, given the INCLUDE variable
INCLUDE=C:COMPILERINCLUDE;S:SOURCEHEADERS;
using the #include <file> version of file inclusion, the compiler first checks the C:COMPILERINCLUDE
directory for the specified file. If the file is not found there, the compiler then checks the
S:SOURCEHEADERS directory. If the file is still not found, the preprocessor checks the current directory.
 
The second way to include files is to surround the file you want to include with double quotation marks. This
method of inclusion tells the preprocessor to look for the file in the current directory first, then look for it in the predefined locations you have set up. Using the #include “file” version of file inclusion and applying
it to the preceding example, the preprocessor first checks the current directory for the specified file. If the
file is not found in the current directory, the C:COMPILERINCLUDE directory is searched. If the file
is still not found, the preprocessor checks the S:SOURCEHEADERS directory.
The #include <file> method of file inclusion is often used to include standard headers such as stdio.h or
stdlib.h. This is because these headers are rarely (if ever) modified, and they should always be read from your
compiler’s standard include file directory. 
The #include “file” method of file inclusion is often used to include nonstandard header files that you have created for use in your program. This is because these headers are often modified in the current directory, and you will want the preprocessor to use your newly modified version of the header rather than the older, unmodified version.
 
总的来说:
当用#include“file.h”时,先搜索当前工作目录,如果没有,再去搜索标准库,库没有再搜索资源库;
当用#include<file.h>时,编译器先从标准库开始搜索,如果没再搜索资源库目录,若还未找到则搜索当前工作目录。

综上,题中的两种方式都会找到stdio.h(存在于标准库)
通过<>,(库里)一步就找到了
通过“”,   由于先从当前目录中找(未找到),再到库中寻找(找到),比前者多了一步,所以花费时间比前者多
编辑于 2015-09-10 21:48:54 回复(4)
个人觉得#include "stdio. h"和#include <stdio. h>体现在编译速度上,程序的执行速度应该一样!
发表于 2015-09-02 17:18:43 回复(1)
为什么A不对?
发表于 2015-06-26 00:09:55 回复(0)
首先要理解一下#include<>和#include" "区别:
#include<>:指的先从INCLUDE环境变量指定的路径(也叫预定义缺省路径)去寻找文件,如果找不到再去当前程序所在的路径下去寻找。
通常一些不易改变的、系统自带的、头文件都会放在 预定义缺省路径下面。
#include" ":查找引入文件的顺序刚好跟上面是相反的,先从 当前程序所在的路径下去寻找,找不到了才会去 预定义缺省路径去寻找文件。
对于上面那道题来说:
(1)两种引入方式都是对的,都可以引入stdio.h。
(2)但是由于stdio.h文件是放在INCLUDE环境变量指定的路径里面,所以 #include<>肯定会快。至于 #include" "为什么会慢,道理很简单
#include<>查找方式: 系统路径( stdio.h我就在这 )-》本地路径
#include" "查找方式: 本地路径-》系统路径 stdio.h我就在这
你说谁快?如果你自己写的程序工程很大有一亿个头文件呢,等这 一亿个头文件 都找完找不到 stdio.h ,才能去系统路径下面找。
发表于 2016-11-24 17:18:35 回复(0)
““和<>的区别是先访问哪个目录,但是include发生在预处理阶段,不是编译阶段,所以编译的用时应该是一样的
发表于 2017-07-07 07:47:05 回复(0)
执行速度是个什么鬼? 居然把编译时间算进去? 莫名其妙
发表于 2015-08-03 15:01:13 回复(2)
h前面的大空子是认真的吗
#include <stdio. h>

发表于 2018-10-22 09:09:26 回复(0)
头文件包含是预处理阶段就处理完毕的,为什么会影响编译的速度?这题应该选C吧,感觉有歧义。
发表于 2018-10-06 12:46:30 回复(0)
#include< file >编译程序会先到标准函数库中找文件 
#include”file” 编译程序会先从当前目录中找文件
发表于 2018-05-08 08:31:16 回复(0)
文件名是stdio.h 所以<> 要比“”先找到
发表于 2018-03-26 23:19:42 回复(0)
影响预处理的速度,头文件最终被整到c文件的副本里,再编译。没看出对编译速度有什么影响!!!
发表于 2018-02-02 06:46:14 回复(0)
当用#include“file.h”时,先搜索当前工作目录,如果没有,再去搜索标准库,库没有再搜索资源库; 当用#include<file.h>时,编译器先从标准库开始搜索,如果没再搜索资源库目录,若还未找到则搜索当前工作目录
发表于 2017-11-22 09:55:27 回复(0)
氵头像
不服,每个都有空格,选D
发表于 2017-03-08 17:17:35 回复(0)
#include <stdio. h>:按标准方式搜索C++系统目录下的include子目录 #include"stdio. h":首先在当前目录中搜索,若没有,在按标准方式搜索

发表于 2016-10-17 21:34:09 回复(0)
引入标准库stdio吗,如果采用
include "stdio.h",那么编译器会先去用户目录查找该文件,发现没有找到,然后去系统库中去找
include <stdio.h>,编译器直接去系统库中查找stdio.h文件,肯定速度快啊

发表于 2016-09-23 19:26:02 回复(0)
B 注释:include   ""是先从本地目录开始寻找,然后去寻找系统路径,而Include   <>   相反先从系统目录,后从本地目录,  
发表于 2016-09-03 15:43:25 回复(0)
语句#include "stdio.h"和#include <stdio.h>都是正确的,要说有区别那也是查找文件的速度不同而已,最终体现到编译速度上快慢而已。
发表于 2016-08-29 21:49:30 回复(0)
<stdio.h> == 默认路径搜索,没找到再到当前目录搜索。  
"stdio.h" == 当前目录搜索,没有找到就会报错。  

所以一般系统的头文件用< >,自己定义的头文件用" "。
发表于 2016-05-31 15:12:55 回复(0)
stdio. h本身是系统的头文件,本地目录是没有的,直接从系统目录找当然更快。
发表于 2015-12-26 20:45:03 回复(0)
B,如果是标准库的话,<>比“”速度快
发表于 2015-10-20 14:08:31 回复(0)