命令'cin'和'cout'不起作用
Commands 'cin' and 'cout' not working
我在Windows 8.1上安装了MinGW,以便用C++进行编码,我正试图使用Sublime Text 3运行我的代码。到目前为止,我是成功的,但我不能使用cin
和cout
。我知道我可以使用scanf
和printf
。但我可能还需要使用cin
和cout
。当我试图构建一个包含cin
或cout
的C++代码时,会出现编译时错误。让我们看看生成这样一个错误的代码:
#include "iostream"
#include "cstdio"
using namespace std;
int main()
{
int n;
std::cin >> n;
std::cout << n;
}
我的机器上出现的错误是:(注意:我在机器上安装了WinGHCi以使用Haskell)
Info: resolving std::cin by linking to __imp___ZSt3cin (auto-import)
Info: resolving std::cout by linking to __imp___ZSt4cout (auto-importc:/program files (x86)/haskell platform/2013.2.0.0/mingw/bin/../lib/gcc/mingw32/4.5.2/../../../../mingw32/bin/ld.exe: warning: auto-importing has been activated without --enable-auto-import specified on the command line.
This should work unless it involves constant data structures referencing symbols from auto-imported DLLs.)
[Finished in 1.4s]
请帮我找出问题所在。我故意不想使用IDE。
请注意,一般建议使用<iostream>
而不是"iostream"
。在这方面,使用<iostream>
在编译相同代码时会产生以下错误("iostream"
和"cstdio"
被<iostream>
&<cstdio>
替换):
Info: resolving std::cin by linking to __imp___ZSt3cin (auto-import)
Info: resolving std::cout by linking to __imp___ZSt4cout (auto-importc:/program files (x86)/haskell platform/2013.2.0.0/mingw/bin/../lib/gcc/mingw32/4.5.2/../../../../mingw32/bin/ld.exe: warning: auto-importing has been activated without --enable-auto-import specified on the command line.
This should work unless it involves constant data structures referencing symbols from auto-imported DLLs.)
[Finished in 1.8s]
当您使用时,这些类型或错误通常会被丢弃
headers with version x
----------------------
lib with version y
所以,检查一下这个。
更新
如果您使用的是4.6.3版本的编译器,但使用的是4.6版本的头(无论出于何种原因),则会出现此类错误。
有用命令:
which g++ #locate where is your compiler (generally /usr/bin/g++)
g++ --version #get compiler's version
find / -name iostream | grep c++ #find where're your includes
相关文章:
- 重载运算符 (<<) cout 在 c ++ 中不起作用,当我互相减去两个矩阵时不起作用
- 指针变量在 cout 函数中不起作用
- Cuda 基本程序 (将值写入矩阵和 std:cout 不起作用) ;主功能不启动
- 我正在使用 VS 代码,但 cout 不起作用
- 为什么“运算符<<(cout,double)”不起作用
- 为什么这个 RAII cout 重定向器不起作用:
- 为什么COUT在朋友函数中不起作用,该功能超载了操作员&lt;&lt;这是一个iStream运算符
- 将字符串转换为char,当我cout时,它是正确的,但是当我将chdir与char一起使用时,它不起作用
- Visual Studios Cout <<不起作用
- 为什么 cout 不起作用?
- std::cout::setf 不起作用(setf 到十六进制)
- C getarea()和cout不起作用
- 为什么当注释"cout"时此代码不起作用?
- 如果后跟返回 (C++),则 cout 不起作用
- C++11 和 boost_filesystem cout 和 printf 不起作用
- 将多个整数添加到一个向量索引? 'Cout'不起作用
- C++ cout 字符串不起作用.请指教
- 在 msgget() 之后,cout 或 printf 不起作用
- 为什么 cout << " "有效,而 wcout << " "不起作用?
- 命令'cin'和'cout'不起作用