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

  • SEARCH
  • Home
  • 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 6809709
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T20:07:06+00:00 2026-05-26T20:07:06+00:00

I have the same problem as mentioned in the linked question. The console window

  • 0

I have the same problem as mentioned in the linked question. The console window (in VS 2010) disappears immediately after running the program. I use a cin.get(); at the end of the main function, but the problem still remains. Any idea about the possible reason? You can check out the code in main:

int main()
{
    const int arraysize = 10;
    int order;
    int counter;
    int a[arraysize] = {2,6,4,45,32,12,7,33,23,98};

    cout<<"Enter 1 to sort in ascending order\n"
        <<"Enter 2 to sort in descending order\n";
    cin>>order;
    cout<<"Data items in original order\n";

    for(counter=0;counter<arraysize;counter++){
        cout<<setw(4)<<a[counter];
    }

    switch (order){
        case 1: cout<<"\nData items in ascending order\n";
                selectionSort(a, arraysize, ascending);
                break;
        case 2: cout<<"\nData items in descending order\n";
                selectionSort(a, arraysize, descending);
                break;
        default: return 0;
    }

    for(counter=0;counter<arraysize;counter++){
        cout<<setw(4)<<a[counter];
    }

    cout<<endl;
    cin.get();

    return 0;
}

link : C++ on Windows – the console window just flashes and disappears. What's going on?

  • 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-26T20:07:06+00:00Added an answer on May 26, 2026 at 8:07 pm

    My guess is that

    default: return 0;
    

    get executed.

    EDIT:

    You’re right, that’s not the issue. Read this.

    The quick fix is:

    cout<<endl;
    cin.ignore(); // <---- ignore previous input in the buffer
    cin.get();
    

    But you might want to read the article for further info on the behavior.

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

Sidebar

Related Questions

I have basically the same problem outlined in this question, however I am using
I have the same question problem as described here How to purge a cached
I seem to have the same problem mentioned here (search why are my spheres
I have the same problem as described in the posts listed below. That is,
I have the same problem as described in ( Last record of Join table
I have the same problem as in the following post . So I am
Solution: if you have the same problem, addElement() instead of addChild() is what did
Does anyone have the same problem as I do? ... I've upgraded to the
I have essentially the same problem discussed here: http://khason.net/blog/dependency-property-getters-and-setters-in-multithreaded-environment/ public static readonly DependencyProperty MyPropertyProperty
I actually have two questions regarding the same problem but I think it is

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.