console-application

What happens when you close a c++ console application

断了今生、忘了曾经 提交于 2019-11-26 22:32:25
I guess the question says it all, but, what happens if someone closes a c++ console app? As in, clicks the "x" in the top corner. Does it instantly close? Does it throw some sort of exception? Is it undefined behavior? Closing a c++ console app with the "x" in the top corner throws an CTRL_CLOSE_EVENT which you could catch and process if you set a control handler using the SetConsoleCtrlHandler function. In there you could override the close functionality and perform whatever you wished to do, and then optionally still perform the default behavior. AndrewR I imagine that the console process

Required widgets for displaying a 1D console application

£可爱£侵袭症+ 提交于 2019-11-26 22:02:42
问题 I am trying to make a 1D console application using Urwid for displaying a user editable application form as shown below. _________________________ | Application Form | | ---------------- | | ' ' | | ' ' | | ---------------- | | | | ---------------- | | ' --------- ' | | ' ' ' ' | | ' --------- ' | | ' ' | | ---------------- | | | |_________________________| Consider the outer rectangle as one window or widget that contains the header title "Application Form" and other smaller windows inside

Unicode input in a console application in Java

血红的双手。 提交于 2019-11-26 21:53:19
问题 I have been trying to retrieve "unicode user input" in my Java application for a small utility snippet. The problem is, it seems to be working on Ubuntu "out of the box" which has I guess OS wide encoding at UTF-8 but doesn't work on Windows when run from "cmd". The code in consideration is as follows: public class SerTest { public static void main(String[] args) throws Exception { testUnicode(); } public static void testUnicode() throws Exception { System.out.println("Default charset: " +

Keeping console window open when debugging

烂漫一生 提交于 2019-11-26 21:50:19
问题 When I start a program without debugging (Ctrl+F5), I have to press a key to close the console window when the program is finished. When I start the program with debugging (F5), the console window closes immediately. Is there an option in Visual Studio that will keep the window open when debugging? (I know of a thousand ways to do it "manually" in code, but I don't want to touch the code.) 回答1: Add a break point to the ending bracket of the main() method. That way if the program finishes

Why the default SynchronizationContext is not captured in a Console App?

僤鯓⒐⒋嵵緔 提交于 2019-11-26 21:39:09
问题 I'm trying to learn more about the SynchronizationContext , so I made this simple console application: private static void Main() { var sc = new SynchronizationContext(); SynchronizationContext.SetSynchronizationContext(sc); DoSomething().Wait(); } private static async Task DoSomething() { Console.WriteLine(SynchronizationContext.Current != null); // true await Task.Delay(3000); Console.WriteLine(SynchronizationContext.Current != null); // false! why ? } If I understand correctly, the await

How can I write fast colored output to Console?

纵饮孤独 提交于 2019-11-26 21:33:08
I want to learn if there is another ( faster ) way to output text to the console application window using C# .net than with the simple Write , BackgroundColor and ForegroundColor methods and properties? I learned that each cell has a background color and a foreground color, and I would like to cache/buffer/write faster than using the mentioned methods. Maybe there is some help using the Out buffer, but I don't know how to encode the colors into the stream, if that is where the color data resides. This is for a retrostyle textbased game I am wanting to implement where I make use of the standard

Avoiding “Press any key to continue” when running console application from Visual Studio

社会主义新天地 提交于 2019-11-26 21:28:33
问题 When running a console application in Visual Studio via "Start without Debugging" ( Ctrl + F5 ), the console remains open at the end of the run asking to Press any key to continue . . . thus requiring to activate the window and hit a key. Sometimes this is not appropriate. Why this matters: At the very moment I write json serialisation code, my workflow goes like this: adapt c# code run a console app that writes file out.json view out.json in the browser with a json viewer do this again and

JTextArea as console

爱⌒轻易说出口 提交于 2019-11-26 21:22:44
问题 I have posted two pieces of code below. Both codes work fine individually. Now, when I run the file Easy, and click on the "Start" button, I want the class AddNumber to be implemented. I mean to say that, instead of the AddNumber running on the console, is there any way I could make AddNumber run in the JTextArea i have created in the first class upon clicking the "Start" button? I thought maybe by action listener?(the way we do in case of buttons) But I'm not sure. Is there any other way to

Changing font in a Console window in .NET

為{幸葍}努か 提交于 2019-11-26 20:55:42
问题 I have built a neat little Console app which basically interacts with ASP.NET projects on a users machine. I have a really trivial need, all I need to do is before I show the Console window, I need to have it a black background, a lime green foreground and a Lucida font. I could achieve the color part by using the static methods of Console class. Although there is nothing in the class which talks about changing fonts? Has anyone been able to change Console font programatically? Any help

C# Count Vowels

心不动则不痛 提交于 2019-11-26 20:43:47
问题 I am learning to program C# and I am trying to count the vowels. I am getting the program to loop through the sentence, but instead of returning vowel count, it is just returning the length of the string. Any help would be greatly appreciated. static void Main() { int total = 0; Console.WriteLine("Enter a Sentence"); string sentence = Console.ReadLine().ToLower(); for (int i = 0; i < sentence.Length; i++) { if (sentence.Contains("a") || sentence.Contains("e") || sentence.Contains("i") ||