C++中不寻常的iostream事件
Unusual iostream happenings in C++?
我有以下程序,它编译良好,没有错误或警告:
#include <iostream>
#include <SDL/SDL.h>
#include <SDL/SDL_opengl.h>
#include "classes.h"
int width = 0;
int height = 0;
int init(int width = 640, int height = 480, int bpp = 32) // needs to be the first statement called in main()
{
SDL_Init(SDL_INIT_EVERYTHING);
SDL_SetVideoMode(width, height, bpp, SDL_OPENGL);
SDL_WM_SetCaption("SpaceInvaders", NULL);
glClearColor(0,0,0,0);
}
void setstates(int width = 640, int height = 480) // needs to be called when the window is resized
{
::width = width;
::height = height;
glViewport(0, 0, width, height);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0, width, 0, height, -1, 1);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
}
int main (int argc, char** argv)
{
setstates();
std::cout << ::width << std::endl;
std::cout << ::height << std::endl;
int a ;
std::cin >> a;
return 0;
}
我发现奇怪的是,当我在主函数中调用cout并运行程序时,控制台出现,但什么都不显示,当我按下一个字母并输入时,程序返回0,就像在cin语句中一样,但控制台甚至不会显示我按下的字母。
然而,我在编译后的程序目录中得到了一个stdout.txt文档,其中显然是用换行符格式化的定制信息。
所以我的问题是问题出在哪里?为什么会发生这种事,我以前从未经历过。
感谢您提前抽出时间
SDL重定向您的输出,如常见问题解答中所述。
相关文章:
- Android NDK传感器向事件队列报告奇怪的间隔
- 是否可以用"iostream"包装现有的TCP/OOpenSSL会话
- 从文本文件中读取时钟时间和事件时间并进行处理
- WMI检测进程创建事件-c++
- EvtExportLogneneneba API正在将远程计算机的事件日志保存到远程PC本身.如何将其保存到主机
- 需要从 istream 和 ostream 派生 iostream
- 处理闪烁窗口事件
- C++Builder中的OnClick事件签名存在问题
- 跟踪滚动条上的鼠标事件
- 什么是事件表 (wxWidgets)?
- 如何在 MFCaptureEngine 中获取"Camera removed"事件
- 给定顺序中的事件处理
- std::带有自定义缓冲区的 iostream 不允许我写入
- 当服务中的事件被触发时,如何将响应从服务发送回客户端?
- 在 C++/CLI 中将 .NET 事件从一个 DLL 引发到另一个 DLL
- 如何创建事件驱动的 SDL2 应用程序
- Windows 进程间同步类似事件?
- 如何从C++端挂接到 QML 项的 onClick 事件
- 如何通过多类"Union variable" (sfml) 使用轮询事件
- C++中不寻常的iostream事件