C++の環境構築がうまくいかない
minGWを入れてC++の環境を作ったのですが、
プログラムによってうまくいくものとそうでないものがあって困っています
c++
1#include <bits/stdc++.h> 2using namespace std; 3 4int main(){ 5 std::cout << "hoge" << std::endl; 6 7 return 0; 8}
上記のプログラムはきちんとhoge
と表示されるのですが、
c++
1#include <cstdio> 2#include <iostream> 3#include <string> 4 5using namespace std; 6 7int main() { 8 string a, b, c; 9 cin >> a >> b >> c; 10 cout << a[0] << b[0] << c[0] << endl; 11 return 0; 12}
上記のプログラムを実行させると、
となって文字列のインプットもできずに終わります
環境
g++ -v Using built-in specs. COLLECT_GCC=g++ COLLECT_LTO_WRAPPER=c:/mingw/bin/../libexec/gcc/mingw32/6.3.0/lto-wrapper.exe Target: mingw32 Configured with: ../src/gcc-6.3.0/configure --build=x86_64-pc-linux-gnu --host=mingw32 --with-gmp=/mingw --with-mpfr=/mingw --with-mpc=/mingw --with-isl=/mingw --prefix=/mingw --disable-win32-registry --target=mingw32 --with-arch=i586 --enable-languages=c,c++,objc,obj-c++,fortran,ada --with-pkgversion='MinGW.org GCC-6.3.0-1' --enable-static --enable-shared --enable-threads --with-dwarf2 --disable-sjlj-exceptions --enable-version-specific-runtime-libs --with-libiconv-prefix=/mingw --with-libintl-prefix=/mingw --enable-libstdcxx-debug --with-tune=generic --enable-libgomp --disable-libvtv --enable-nls Thread model: win32 gcc version 6.3.0 (MinGW.org GCC-6.3.0-1)
gcc version 6.3.0 (MinGW.org GCC-6.3.0-1)です。
エディタはSublime Text 3ですが、コンパイルはコマンドプロンプト上で行っています
Windows なら Visual Studio をインストールしたほうがC++環境の構築は楽だと思いますよ
回答3件
あなたの回答
tips
プレビュー