首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >命令cin和cout无效

命令cin和cout无效
EN

Stack Overflow用户
提问于 2014-09-29 14:22:42
回答 1查看 4.1K关注 0票数 1

我在Windows8.1上安装了MinGW,以便在C++中编写代码,并且我试图使用崇高文本3运行我的代码。到目前为止,我是成功的,但我不能使用cincout。我知道我可以用scanfprintf代替。但我可能也需要使用cincout。当我试图构建包含cincoutcin代码时,它会给出编译时错误。让我们看看生成这样一个错误的代码:

代码语言:javascript
运行
复制
#include "iostream"
#include "cstdio"
using namespace std;

int main()
{
    int n;
    std::cin >> n;
    std::cout << n;
}

我的机器上出现的错误是:(注意到:我在我的机器上安装了WinGHCi以使用Haskell)

代码语言:javascript
运行
复制
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" ):

代码语言:javascript
运行
复制
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]
EN

回答 1

Stack Overflow用户

发布于 2014-09-29 14:30:57

这些类型或错误在使用时经常会被抛出:

代码语言:javascript
运行
复制
 headers with version x
 ----------------------
 lib with version y

所以,看看这个。

更新

如果您使用的编译器版本为4.6.3,但是您使用的标头为4.6 (出于任何原因),则会出现此类错误。

有用的命令:

代码语言:javascript
运行
复制
 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
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/26102176

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档