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 6136485
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T17:36:30+00:00 2026-05-23T17:36:30+00:00

Im looking for a way to hide the console (in windows) in my program,

  • 0

Im looking for a way to hide the console (in windows) in my program, and ive found this code:

#if defined (__WIN32__)
    #include <windows.h>
    HWND hWnd = GetConsoleWindow();
    ShowWindow(hWnd, SW_HIDE);
#endif

however, codeblocks keeps on giving me error: expected constructor, destructor, or type conversion before '(' token. what am i doing wrong?

what are codes of hide the console in mac and linux? I dont use mac or linux too often, but i want to make my programs platform independent. is there a code that works in all platforms? does the console even show up in mac and linux when compiling?

  • 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-23T17:36:31+00:00Added an answer on May 23, 2026 at 5:36 pm

    In general, console applications shouldn’t mess with their window. If you need more advanced stuff (show/hide your window, decide its size, …) you should probably switch to a GUI application. This holds true even if you just don’t want any window: create a GUI application and don’t create windows.

    On Mac and Linux no console is shown by default when you start an executable (and there’s no distinction between GUI and console executables); if you start it in a terminal, the application don’t have much control over it (unless it uses escape codes, but they are to control text formatting/positioning). You can use some heuristic to guess the terminal emulator used and tell it to hide, but it’s ugly, cumbersome and, again, defeats the purpose of a console application.

    As far as your code snippet is concerned, you can’t put that #include inside a function body: you should split that stuff in two pieces:

    At the top of the file:

    #ifdef __WIN32__
        #define _WIN32_WINNT 0x0500
        #include <windows.h>
    #endif
    

    inside the function body:

    #ifdef __WIN32__
        ShowWindow(GetConsoleWindow(), SW_HIDE);
    #endif
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm looking for a way to show/hide an arbitrary RichFaces component. In this case,
I'm looking for some way to effectively hide inherited members. I have a library
I'm looking for the easiest possible way to hide an UpdatePanel while waiting for
I realize there's a way in Vim to hide/fold lines, but what I'm looking
I'm looking a way to enable IP logging with log4net in ASP.NET. I found
I am using jQuery currently and I am looking for a way to hide
I was looking for a way to include an expand all and collapse all.
I'm looking for a way to hide all elements of a particular class -
I'm looking for a way to show and hide the statusbar with an onClickListener
I’m looking for an easy way to hide everything except a certain div and

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.