はじめに
以下のエラーが出ます。
c1.cpp:1:10: fatal error: 'bits/stdc++.h' file not found
#include <bits/stdc++.h>
まず以下の記事にあるように、stdc++.h をダウンロードして配置します。
'bits/stdc++.h' file not foundの対処法 #C++ - Qiita
次に出たエラー
cout
が無いと言われます。
c1.cpp:5:3: error: use of undeclared identifier 'cout'; did you mean 'count'?
cout << "Hello" << endl;
^~~~
count
解決策
#include <iostream>
を書けばいいのですが、そもそも stdc++.h
に入っているはずなので、書きたくありません。
ダウンロードした stdc++.h
から #include <iostream>
を探すと、なにやら #if
〜#endif
の中に入っています。
この行をどこでも良いから #if
〜#endif
の外に出します。必ず #include
されるようにします。自分で使うだけだから、自分の環境だけ動けば良いです。
これでコンパイルできるようになりました。
環境
ProductName: Mac OS X
ProductVersion: 10.15.7
BuildVersion: 19H1713
Xcode 12.4
Build version 12D4e
Target: x86_64-apple-darwin19.6.0
LANG=ja_JP.UTF-8
zsh 5.7.1 (x86_64-apple-darwin19.0)
x64