How do you clear the console screen in C?

printf(“\e[1;1H\e[2J”); This function will work on ANSI terminals, demands POSIX. I assume there is a version that might also work on window’s console, since it also supports ANSI escape sequences. #include <unistd.h> void clearScreen() { const char *CLEAR_SCREEN_ANSI = “\e[1;1H\e[2J”; write(STDOUT_FILENO, CLEAR_SCREEN_ANSI, 12); } There are some other alternatives, some of which don’t move the … Read more

How do I get a return value from Task.WaitAll() in a console app?

You don’t get a return value from Task.WaitAll. You only use it to wait for completion of multiple tasks and then get the return value from the tasks themselves. var task1 = GetAsync(1); var task2 = GetAsync(2); Task.WaitAll(task1, task2); var result1 = task1.Result; var result2 = task2.Result; If you only have a single Task, just … Read more

Using UTF-8 Encoding (CHCP 65001) in Command Prompt / Windows Powershell (Windows 10)

Note: This answer shows how to switch the character encoding in the Windows console to (BOM-less) UTF-8 (code page 65001), so that shells such as cmd.exe and PowerShell properly encode and decode characters (text) when communicating with external (console) programs with full Unicode support, and in cmd.exe also for file I/O.[1] If, by contrast, your … Read more

how to run a winform from console application?

The easiest option is to start a windows forms project, then change the output-type to Console Application. Alternatively, just add a reference to System.Windows.Forms.dll, and start coding: using System.Windows.Forms; [STAThread] static void Main() { Application.EnableVisualStyles(); Application.Run(new Form()); // or whatever } The important bit is the [STAThread] on your Main() method, required for full COM … Read more

Error message “CS5001 Program does not contain a static ‘Main’ method suitable for an entry point”

It means that you don’t have a suitable entry point for your application at the moment. That code will nearly work with C# 7.1, but you do need to explicitly enable C# 7.1 in your project file: <LangVersion>7.1</LangVersion> or more generally: <LangVersion>latest</LangVersion> You also need to rename MainAsync to Main. So for example: Program.cs: using … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)