console-application

User input without pausing code (c++ console application)

◇◆丶佛笑我妖孽 提交于 2019-12-01 14:17:12
How can I enter an input without causing the code to stop executing? I have been searching for an answer during the last 20 minutes without result. cin >> string; pauses the code AFAIK. Would I need to use mulithreading, or is there a better way? (I don't even know if multithreading would work.) I've recently started learning c++, I am a beginner to say the least, so please explain thoroughly and include any library I might need, thank you. There are two algorithms for getting input without blocking (pausing). The first is polling, the second is by event (interrupt). Polling For Input Polling

Why am I getting this error: not all code paths return a value?

可紊 提交于 2019-12-01 14:13:24
hi im new to c# and was trying to code but getting error can anybody help me with this what am i doing wrong? using System; using System.Collections.Generic; using System.Text; namespace hodder { class Program { public static void Main() { isHodder(3); } static int isHodder(int n) { int k = n; for (int i = 2; i <= n / 2;i++ ) { if ((n % 1) == 0) { return 0; } else { for (int j = 2; j <= k;j++ ) { if (n == (2^ j) - 1) { return 1; } else { return 0; } k=(2^j)-1; } } } } } } im getting error on " static int isHodder(int n) " 'hodder.Program.isHodder(int)': not all code paths return a value and

How to print 2D array to console in C#

假如想象 提交于 2019-12-01 13:32:05
问题 I dont't have any code for this, but I do want to know how I could do this. I use visual studio 2010 C# if that matters. Thanks Jason 回答1: public static void Print2DArray<T>(T[,] matrix) { for (int i = 0; i < matrix.GetLength(0); i++) { for (int j = 0; j < matrix.GetLength(1); j++) { Console.Write(matrix[i,j] + "\t"); } Console.WriteLine(); } } 回答2: you can print it all on one line int[,] array2D = new int[,] { { 1, 2 }, { 3, 4 }, { 5, 6 }, { 7, 8 } }; Console.WriteLine(String.Join(" ",

ProcessStartInfo Multiple Arguments

≡放荡痞女 提交于 2019-12-01 13:12:32
问题 I have an ASP.NET Web Form which was timing out when sending over 1800 emails whose addresses were being obtained from a DB. So I'm attempting to send the emails from a console application instead - I will access the DB there. I need to pass the email subject line and body text as parameters to the ProcessStartInfo method but need guidance with the syntax. Can anyone help? Specifically, if I concatenate the subject and body vars and separate them with a space, will that suffice or will spaces

Parsing an excel file and reading a cell

大城市里の小女人 提交于 2019-12-01 12:36:25
问题 I got an excel file. I have uploaded the screenshot. I need to write a .NET application (console application) to parse the excel file. You can see a cell titled "Function Name". My .NET app should find that particular cell and read the contents in that column such as Template, InstanceFromTemplate, Task and so on. If it reads Task, it should call CreateTask function like Task(); If it reads InstanceFromTemplate, it should call InstanceFromTemplate function like TaskInstanceFromTemplate(); I

Why am I getting this error: not all code paths return a value?

断了今生、忘了曾经 提交于 2019-12-01 12:29:50
问题 hi im new to c# and was trying to code but getting error can anybody help me with this what am i doing wrong? using System; using System.Collections.Generic; using System.Text; namespace hodder { class Program { public static void Main() { isHodder(3); } static int isHodder(int n) { int k = n; for (int i = 2; i <= n / 2;i++ ) { if ((n % 1) == 0) { return 0; } else { for (int j = 2; j <= k;j++ ) { if (n == (2^ j) - 1) { return 1; } else { return 0; } k=(2^j)-1; } } } } } } im getting error on

System.Runtime.InteropServices.COMException: Retrieving the COM class factory for component with CLSID {58968145-CF05-4341-995F-2EE093F6ABA3} failed

随声附和 提交于 2019-12-01 11:16:58
问题 I am running a c# application and I am using DSOFile dll. This DLL is referenced in the project. I am able to run the exe in my development machine. But when I run the exe in another machine, I am getting Unhandled Exception: System.Runtime.InteropServices.COMException: Retrieving the COM class factory for component with CLSID {58968145-CF05-4341-995F-2EE093F6ABA3} failed due to the following error: 80040154 Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG)). Not

Iterating until int.MaxValue reached

匆匆过客 提交于 2019-12-01 10:51:52
As a little test I wanted to see how long it would take to count to int.MaxValue in a C# console application. Every few hours I checked the progress. Last night when I thought the program would be done executing, it was executing back to 0. I'm not sure why that happened and I was wondering if anyone could explain it to me. What it did was that it counted to 2,147,483,647 then when this value was reached it began counting backwards to zero. Even though it appeared to be counting backwards, the value had a negative number. I wonder if I needed to use the absolute value of int.MaxValue. Anyway,

Modifying text in the terminal

▼魔方 西西 提交于 2019-12-01 08:34:47
Is it possible to modify text I printed to the terminal without clearing the screen? For instance, if I'm showing progress of something in percentage, can I modify that percentage without having to clear the screen and printing again? I'm looking for a cross-platform way, if there is one. Talking C++. thanks There are a number of ways to do this, and depending on how much effort you want to put into it, you can do a lot of cool things with ascii text in a terminal window. Advanced: ncurses library Easier: ansi escape characters with printf or cout Easiest: As others have said, simply use \r

Using static void Main() method from base class as a program's entry point

久未见 提交于 2019-12-01 08:19:11
问题 I would like to abstract some program logic to a base class for executing a command-line program (functionality similar to what this question was requesting). in other words, something like this: public abstract class BaseProgram<T> { public static void Main(string[] args) { Console.WriteLine(typeof(T)); } } public class Program : BaseProgram<string> { } It is important to note that BaseProgram is in a different assembly. This, however, does not work. The static void Main(string[] args)