简体   繁体   中英

how to prevent the console windows to close in ghc app?

When my windows console app compiled with ghc going to it's end, the console window instantly closes. That is good sometimes, but not very good when I want to read some text output from it. So, now I adding this ugly code to my app:

    main =
       do
        ...HERE IS THE CODE ...

        putStrLn " $$ Every thing have passed well $$ /n Press Enter "
        _ <- getLine
        return ()

And this is quite ugly, and more, when some error crashes my app, the console window closes. An other way around to run program in 'cmd' console, but it is not comfortable sometimes. Is there any good looking and convenient way for handling program output?

You could just write a trivial shell script like

MyApp.exe
PAUSE

Save that as RunIt.cmd or something, and then double-click that to run the application. It will open a console window, and wait for you to press any key before the window shuts, regardless of what Haskell does.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM