Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7182875
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T17:51:49+00:00 2026-05-28T17:51:49+00:00

I have the following program which compiles fine and with no errors or warnings:

  • 0

I have the following program which compiles fine and with no errors or warnings:

#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;
}

What I am finding curious is when I call cout in the main function and I am running the program, the console appears and displays nothing, when I press a letter and enter, the program returns 0 as if it were at the cin statement but the console will not even display the letter I have pressed.

I do however get a stdout.txt document in the compiled program directory with what is apparently the cout’ed information formatted by a newline as it is in the program.

Therefore my question is what is the problem? and why is this happening, I have never experienced it before.

Thank you for your time in advance

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T17:51:50+00:00Added an answer on May 28, 2026 at 5:51 pm

    SDL redirects your output, as mentioned in the FAQ.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following c program which launches a Gtk Program on ubuntu: #include
I have a C program which compiles and runs fine under Linux without any
let us have a situation in which the following program prints some 10 lines
I have the following program: ~/test> cat test.cc int main() { int i =
I have the following code. #include <set> #include <algorithm> using namespace std; int _tmain(int
I have the following code which assembles and runs fine on Windows XP 32
I have a ATL COM service exe (MyService.exe), which compiles and runs fine. If
I have a small C++ library, compiles fine on Linux (which is my main
I have the following code, which works fine , however when I change the
I have the following code which should put programs startable in Bash. if [

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.