console window needs closed~

This is a discussion on console window needs closed~ within the C++ Programming forums, part of the General Programming Boards category; The window of a project needs to shut off but I didnt know how to do. any help ? Regards~...

  1. #1
    flashing vampire black's Avatar
    Join Date
    May 2002
    Posts
    563

    Arrow console window needs closed~

    The window of a project needs to shut off but I didnt know how to do. any help ?

    Regards~
    Never end on learning~

  2. #2
    looking for the truth moemen ahmed's Avatar
    Join Date
    Feb 2002
    Location
    Egypt
    Posts
    161
    what do u mean by needs to be closed??????????
    Programming is a high logical enjoyable art for both programer and user !!

  3. #3
    Registered User
    Join Date
    May 2002
    Posts
    23

    Uhhhmm..

    Uhhhmm.. you mean return 0;?

  4. #4
    Registered User C_Coder's Avatar
    Join Date
    Oct 2001
    Posts
    523
    Do you mean you want to have a console program that dosent create a console window?
    If so then write it as a window app :
    Code:
    #include <windows.h>
    #include <stdio.h>
    
    int WinMain( HINSTANCE hThisInst, HINSTANCE hPrevInst, LPSTR lpszArgs, int nWinMode )
    {
    	FILE *fp;
    
    	if( ( fp = fopen( "temp.txt", "wt" ) ) != NULL )
    		fprintf( fp, "NO CONSOLE!!!" );
    
    	return 0;
    }
    just put your console code in a WinMain function.
    All spelling mistakes, syntatical errors and stupid comments are intentional.

  5. #5
    flashing vampire black's Avatar
    Join Date
    May 2002
    Posts
    563
    Originally posted by C_Coder
    Do you mean you want to have a console program that dosent create a console window?
    If so then write it as a window app :
    Code:
    #include <windows.h>
    #include <stdio.h>
    
    int WinMain( HINSTANCE hThisInst, HINSTANCE hPrevInst, LPSTR lpszArgs, int nWinMode )
    {
    	FILE *fp;
    
    	if( ( fp = fopen( "temp.txt", "wt" ) ) != NULL )
    		fprintf( fp, "NO CONSOLE!!!" );
    
    	return 0;
    }
    just put your console code in a WinMain function.
    woh~ I coulnt understand it this time. is there any simply way ?
    Never end on learning~

  6. #6
    Registered User
    Join Date
    Jan 2002
    Posts
    559
    That code doesn't compile on MSVC6. Haven't programmed windows much in C++, but didn't work as a source file or win32 application.
    Truth is a malleable commodity - Dick Cheney

  7. #7
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231
    Originally posted by salvelinus
    That code doesn't compile on MSVC6. Haven't programmed windows much in C++, but didn't work as a source file or win32 application.
    I believe that's 'cos it's missing WINAPI
    Code:
    int WINAPI WinMain(HINSTANCE hThisInst, HINSTANCE hPrevInst, LPSTR lpszArgs, int nWinMode)
    ....
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

  8. #8
    Registered User C_Coder's Avatar
    Join Date
    Oct 2001
    Posts
    523
    >> I believe that's 'cos it's missing WINAPI
    DOH, how did I leave that out!!!!

    >> woh~ I coulnt understand it this time. is there any simply way
    That is simple, your just putting your console code in a windows app. All you need do is have a WinMain() instead of a main(), not forgetting the WINAPI of course
    Last edited by C_Coder; 07-10-2002 at 12:41 PM.
    All spelling mistakes, syntatical errors and stupid comments are intentional.

  9. #9
    Registered User
    Join Date
    Jan 2002
    Posts
    559
    Still didn't work. Compiled but didn't link
    PHP Code:
    inking...
    LIBCD.lib(crt0.obj) : error LNK2001unresolved external symbol _main
    Debug
    /Cpp2.exe fatal error LNK11201 unresolved externals
    Error executing link
    .exe.

    Cpp2.exe 2 error(s), 0 warning(s
    I cut and pasted the code above, adding the winapi. Running MSVC 6 Enterprise.
    Truth is a malleable commodity - Dick Cheney

  10. #10
    Registered User
    Join Date
    Jul 2002
    Posts
    273
    It didn't compile because there are some precompiler linking settings that need to be set up. If you are using VC++, just create a new project as Win32 project and not a Win32 console project.

  11. #11
    flashing vampire black's Avatar
    Join Date
    May 2002
    Posts
    563
    Guys, Winapi should be mentioned anyway ? I know nothing about it. I'm used to programming under console, that's all.
    Never end on learning~

  12. #12
    Registered User
    Join Date
    Jan 2002
    Posts
    559
    Originally posted by Hershlag
    It didn't compile because there are some precompiler linking settings that need to be set up. If you are using VC++, just create a new project as Win32 project and not a Win32 console project.
    Hmm, I'll look into that. Thought I did that, but will try again.
    Truth is a malleable commodity - Dick Cheney

  13. #13
    Registered User C_Coder's Avatar
    Join Date
    Oct 2001
    Posts
    523
    >> Guys, Winapi should be mentioned anyway ? I know nothing about it.
    Geez its not hard, WINAPI WinMain() is just a windows version of main() for the console.
    >> Still didn't work. Compiled but didn't link
    >> unresolved external symbol _main
    You must have created a console project as it is look for main()
    All spelling mistakes, syntatical errors and stupid comments are intentional.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. SDL Window opening with Console Window
    By carrotcake1029 in forum Windows Programming
    Replies: 2
    Last Post: 12-23-2008, 03:32 PM
  2. Console window in VC 2008
    By swgh in forum Tech Board
    Replies: 0
    Last Post: 06-05-2008, 04:13 PM
  3. creating a child window
    By rakan in forum Windows Programming
    Replies: 2
    Last Post: 01-23-2007, 03:22 PM
  4. 6 measly errors
    By beene in forum Game Programming
    Replies: 11
    Last Post: 11-14-2006, 11:06 AM
  5. opengl code not working
    By Unregistered in forum Windows Programming
    Replies: 4
    Last Post: 02-14-2002, 10:01 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21