-
2022-01-22 17:44:15
#include<bits/stdc++.h>介绍:
最近写编程题时发现了一个神奇的头文件,#include<bits/stdc++.h>,很多人在只要引用了这个头文件之后,就无须再引用其他头文件,百度之后感觉挺有用的,写题时方便快捷(不建议经常使用,如果长期使用容易把库函数名字淡忘掉)
使用:
使用前 #include <iostream> #include <cstdio> #include <fstream> #include <algorithm> #include <cmath> #include <deque> #include <vector> #include <queue> #include <string> #include <cstring> #include <map> #include <stack> #include <set> using namespace std; int main(){ return 0; }
使用后 #include<bits/stdc++.h> using namespace std; int main(){ return 0; }
如何调用:
- DEV C++软件可直接使用 #include <bits/stdc++.h>
- VS不行,需先在VS中添加此头文件,方法如下
1.在安装路径下,依次进入:
VC --> Tools --> MSVC --> 14.13.26128(此文件夹名每个人会有不同) --> include
大致是这么个方向,但是要以实际情况为准
D:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.13.26128\include\bits
这是别人的C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include
这是我的路径如果实在找不到,建议下一个Everything,全局搜索include,然后进行一个个比对看看哪个目录中含有自己用的头文件(如最常见的stdio.h),就是这个啦
2.在 include 文件夹下新建一个 bits 文件夹,在此文件夹下添加 stdc++.h 头文件,内容就是以下代码块中的代码
// C++ includes used for precompiling -*- C++ -*- // Copyright (C) 2003-2015 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the // Free Software Foundation; either version 3, or (at your option) // any later version. // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // <http://www.gnu.org/licenses/>. /** @file stdc++.h * This is an implementation file for a precompiled header. */ // 17.4.1.2 Headers // C #ifndef _GLIBCXX_NO_ASSERT #include <cassert> #endif #include <cctype> #include <cerrno> #include <cfloat> #include <ciso646> #include <climits> #include <clocale> #include <cmath> #include <csetjmp> #include <csignal> #include <cstdarg> #include <cstddef> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #if __cplusplus >= 201103L #include <ccomplex> #include <cfenv> #include <cinttypes> #include <cstdalign> #include <cstdbool> #include <cstdint> #include <ctgmath> #include <cwchar> #include <cwctype> #endif // C++ #include <algorithm> #include <bitset> #include <complex> #include <deque> #include <exception> #include <fstream> #include <functional> #include <iomanip> #include <ios> #include <iosfwd> #include <iostream> #include <istream> #include <iterator> #include <limits> #include <list> #include <locale> #include <map> #include <memory> #include <new> #include <numeric> #include <ostream> #include <queue> #include <set> #include <sstream> #include <stack> #include <stdexcept> #include <streambuf> #include <string> #include <typeinfo> #include <utility> #include <valarray> #include <vector> #if __cplusplus >= 201103L #include <array> #include <atomic> #include <chrono> #include <condition_variable> #include <forward_list> #include <future> #include <initializer_list> #include <mutex> #include <random> #include <ratio> #include <regex> #include <scoped_allocator> #include <system_error> #include <thread> #include <tuple> #include <typeindex> #include <type_traits> #include <unordered_map> #include <unordered_set> #endif
3. 之后VS 就可以直接添加头文件 #include <bits/stdc++.h> 使用了。
更多相关内容 -
visual studio中若要使用#include <bits/stdc++.h>,需手动添加头文件:stdc++.h
2020-05-07 03:28:05visual studio中,若要使用#include <bits/stdc++.h>,则需手动添加头文件:stdc++.h,visual studio不自带,#include <bits/stdc++.h>是万能头文件,在平时自己敲代码或者online judge懒得一行一行敲头文件的时候都... -
手动添加bits/stdc++.h到vs2017的详细步骤
2020-08-25 02:16:36主要介绍了手动添加bits/stdc++.h到vs2017的详细步骤,本文给大家介绍的非常详细,具有一定的参考借鉴价值,需要的朋友可以参考下 -
C++万能头: bits/stdc++.h 下载
2021-10-15 17:48:48请按照相关教程将此放置在对应的目录即可识别: 支持众多IDE如:DEV-C++、VS软件、VS Code…… -
Visual Studio添加#include<bits/stdc++.h>
2022-05-17 17:59:01新建bits目录,新建文件stdc++.h文件 添加如下代码 // C #ifndef _GLIBCXX_NO_ASSERT #include <cassert> #endif #include <cctype> #include <cerrno> #include <cfloVisual Studio 2022社区版
进入C:\Program Files (x86)\Windows Kits\10\Include\10.0.19041.0\ucrt
新建bits目录,新建文件stdc++.h文件
添加如下代码
// C #ifndef _GLIBCXX_NO_ASSERT #include <cassert> #endif #include <cctype> #include <cerrno> #include <cfloat> #include <ciso646> #include <climits> #include <clocale> #include <cmath> #include <csetjmp> #include <csignal> #include <cstdarg> #include <cstddef> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #if __cplusplus >= 201103L #include <ccomplex> #include <cfenv> #include <cinttypes> #include <cstdalign> #include <cstdbool> #include <cstdint> #include <ctgmath> #include <cwchar> #include <cwctype> #endif // C++ #include <algorithm> #include <bitset> #include <complex> #include <deque> #include <exception> #include <fstream> #include <functional> #include <iomanip> #include <ios> #include <iosfwd> #include <iostream> #include <istream> #include <iterator> #include <limits> #include <list> #include <locale> #include <map> #include <memory> #include <new> #include <numeric> #include <ostream> #include <queue> #include <set> #include <sstream> #include <stack> #include <stdexcept> #include <streambuf> #include <string> #include <typeinfo> #include <utility> #include <valarray> #include <vector> #if __cplusplus >= 201103L #include <array> #include <atomic> #include <chrono> #include <condition_variable> #include <forward_list> #include <future> #include <initializer_list> #include <mutex> #include <random> #include <ratio> #include <regex> #include <scoped_allocator> #include <system_error> #include <thread> #include <tuple> #include <typeindex> #include <type_traits> #include <unordered_map> #include <unordered_set> #endif
-
VS Code #include <bits/stdc++.h> 错误
2021-12-10 03:00:26在其他文章中有一种解决办法是复制 bits/stdc++.h (需要新建bits文件夹)到 msvc 编译器的 include 文件夹下,然后可以识别了,但由于其改动了 msvc 的库,所以不推荐使用此方法。 实际上这个问题原因就是 bits/...提示:
正常情况你需要使用 MinGW g++ 编译器才可以使用 bits/stdc++.h
在其他文章中有一种解决办法是复制 bits/stdc++.h (需要新建bits文件夹)到 msvc 编译器的 include 文件夹下,然后可以识别了,而且在 msvc 中也能使用 bits/stdc++.h,但由于其改动了 msvc 的库,所以不推荐使用此方法。
实际上这个问题原因就是 bits/stdc++.h 是由 MinGW 提供的,而 VS Code 默认使用 msvc 和 windows-msvc-x64 intellisense,msvc 里根本没有这个文件。
具体操作:
1. 点击 VS Code 右下角的 "Win32"
2. 编辑配置(UI)
3. 编译器路径修改为你 mingw g++ 的路径,IntelliSense mode 修改为 windows-gcc-x64
OK
为了更好的辨识性,我将这个配置命名为 MinGW-g++,上述修改也可以在 C/C++ 插件的 .json 配置文件中操作。
题外话:
由于其便利性 bits/stdc++.h 在算法竞赛中经常被使用,被称为万能头文件,但它也有些缺点:
1. stdc++.h(以及 bits 下的所有文件)不属于 C++ 标准(所以 msvc 里没有这东西),需要特定编译器编译,实际开发中应该避免 compiler-specific 的代码,也就是需要特定编译器才能过编译的代码。
2. 看代码的人难以得知你具体使用了 stdc++.h 里面的哪些东西。
3. 你的电脑将会编译 stdc++.h 里 include 的每一个文件。所以实际开发中不该使用 bits/stdc++.h
-
bits/stdc++.h
2017-08-30 19:58:27放到usr/local/bits/下,命名为stdc++.h,然后在c++代码中#include<bits/stdc++.h>就可以在mac系统下使用这个头文件了。 -
VS #include<bits/stdc++.h>报错解决办法
2022-04-21 12:56:061.找到MINGW下的stdc++.h文件: 2.将该bits文件夹复制到vs的引用文件目录下: 3.测试1.找到MINGW下的stdc++.h文件:
2.将该bits文件夹复制到vs的引用文件目录下:
3.测试 -
vscode 添加万能头文件#include<bits/stdc++.h>
2022-01-22 13:45:31这就是c_cpp_properties.json了 如果你电脑装了visual studio,或者wsl(windows下Linux子系统),vscode会优先用前两者的编译器,如果前两个都没检测到,vscode才会使用Mingw的gcc/g++ 而bits/stdc++.h这个万能... -
C++的万能头文件 #include<bits/stdc++.h>
2021-12-21 22:20:42#include<bits/stdc++.h> 该头文件包含了目前C++的所有头文件,举个栗子: 有些时候我们可能需要调用大量库文件,比如像这样 #include <iostream> #include <cstdio> #include <fstream> ... -
Visual Studio 中使用万能头文件 #include <bits/stdc++.h>
2022-01-10 21:05:16bits/stdc++.h> ,但VS中并没有,为了使用方便,可直接在VS中添加此头文件,方法如下: #include<bits/stdc++.h>包含了目前c++所包含的所有头文件!!!! 操作步骤 1.在安装路径下,依次进入: VC -->... -
mac版的vscode添加一个库stdc++.h #include <bits/stdc++.h>
2021-08-17 16:54:29一、应用程序然后找Xcode.app接着右键选择显示包内容选项,最后按如下路径找到include文件 /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include 二 、... -
【C++的万能超级无敌头文件 #include <bits/stdc++.h> 】
2020-11-03 20:13:26bits/stdc++.h> 这个头文件竟然包含了C++里边所有的头文件,也就是一个“万能的头文件”! 比如说:它包含了: #include <iostream> #include <cstdio> #include <fstream> #include <... -
C++万能头文件 #include <bits/stdc++.h>
2022-01-17 13:46:27相信CSDN的开发者们在写某些小游戏的时候总会遇到一些难题,比如—— 想要延迟,Sleep(xxx),可是必须要 #include <ctime> 的头文件才行,怎么办? 要 #include <ctime>...bits/stdc++.h&g -
C++万能头文件——#include<bits/stdc++.h>
2021-09-22 16:19:26bits/stdc++.h>包含了目前c++所包含的所有头文件!!!! 对比 使用前: #include <iostream> #include <cstdio> #include <fstream> #include <algorithm> #include <cmath> #... -
征集—不在 # include <bits/stdc++.h> 里的头文件
2022-02-19 11:40:22请在评论区回答 -
C++万能头文件#include<bits/stdc++.h>
2021-04-18 16:12:19bits/stdc++.h> ** 源代码 // C++ includes used for precompiling -*- C++ -*- // Copyright (C) 2003-2014 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This ... -
在VS中使用万能头文件#include <bits/stdc++.h>编译错误的解决方法
2021-03-30 13:57:08我这里只是把它翻译地更加浅显一点: solution to include bits/stdc++.h in visual c++ By Tensor, 2 years ago, , This is just a method i used to make me able to include bits/stdc++.h in visual c++.... -
VS 配置#include<bits/stdc++.h>
2021-02-07 22:58:39bits/stdc++.h> 前言 上次介绍了#include<bits/stdc++.h>的优劣,自己上手发现VS识别不了?! 解决办法 打开文件夹C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.28.... -
万能头文件#include<bits/stdc++.h>
2021-06-18 17:24:18bits/stdc++.h>这个头文件包含以下等等C++中包含的所有头文件: #include #include #include #include #include #include #include #include #include #include #include #include #include 等等... -
#include<bits/stdc++.h>介绍
2021-02-05 10:47:20bits/stdc++.h> 这样一个头文件,那这个是什么意思呢? 其实这个是一个万能头文件,相当于以下的代码 #include <iostream> #include <cstdio> #include <fstream> #include <algorithm&... -
关于头文件#include<bits/stdc++.h>
2021-01-29 12:18:30#include<bits/stdc++.h>的优缺点 1.它适用于编程竞赛,可以节省选手精力 2.在项目开发的过程,使用此头文件会增加内存大小和延长运行速度 3.部分c++编译器不支持该头文件 ... -
关于#include<bits/stdc++.h>头文件的问题
2021-02-14 21:13:15bits/stdc++.h>就不好使 用#include<iostream>就可以 bits/stdc++.h不是包括iostream吗 #include<bits/stdc++.h> using namespace std; int M,N,L,T; int a[60][1286][128];//最多60层1286行128列 ... -
C++万能头文件#include <bits/stdc++.h>
2021-03-17 15:46:32include<bits/stdc++.h>包含了目前c++所包含的所有头文件!!!写了它一般就不用再加其他头文件了! 惊不惊喜! -
VScode 无法使用C++万能头文件#include<bits/stdc++.h> 解决方案
2020-12-20 05:15:59在刷题的时候,使用万能头文件 #include,但是vscode无法识别,找不到头文件。问题出在路径中没有这个文件,所以创建这个文件。红波浪线报错解决方案,亲测有效在代码的头文件加入#include,右键转到定义屏幕快照 ... -
C++ 万能头文件 #include<bits/stdc++.h>
2020-07-21 20:44:06bits/stdc++.h>头文件,其实该头文件是一个c++万能头文件,包含遇到的所有有文件。 其实这是一个包含了C++所有头文件的一个头文件,为了方便而发明的,其中包含了一下头文件: //c #ifndef _GLIBCXX_NO_ASSERT #... -
#include<bits/stdc++.h>
2019-04-10 19:12:00#include<bits/stdc++.h>包含了目前c++所包含的所有头文件 转载于:https://www.cnblogs.com/wendiudiu/p/10685442.html -
MAC用户如何为Xocde配置#include <bits/stdc++.h>的万能头文件
2021-12-08 23:06:17众所周知,ACM里有一个强大的神器便是“bits/stdc++.h”,然而在Xcode中include这个头文件却报错,原因是stdc++.h是gcc特有的,而Xcode的c++编译器是clang,所以不能用万能头 解决方法就是手写一个stdc++.h用 方法1:...