console-application

Is there a simple way to get the number of characters printed in C++?

我的未来我决定 提交于 2020-01-03 08:37:12
问题 printf(...) returns the number of characters output to the console, which I find very helpful in designing certain programs. So, I was wondering if there is a similar feature in C++, since the cout<< is an operator without a return type (at least from what I understand of it). 回答1: You can associate your own streambuf to cout to count the characters. This is the class that wraps it all: class CCountChars { public: CCountChars(ostream &s1) : m_s1(s1), m_buf(s1.rdbuf()), m_s1OrigBuf(s1.rdbuf(&m

Is there a simple way to get the number of characters printed in C++?

我的未来我决定 提交于 2020-01-03 08:37:08
问题 printf(...) returns the number of characters output to the console, which I find very helpful in designing certain programs. So, I was wondering if there is a similar feature in C++, since the cout<< is an operator without a return type (at least from what I understand of it). 回答1: You can associate your own streambuf to cout to count the characters. This is the class that wraps it all: class CCountChars { public: CCountChars(ostream &s1) : m_s1(s1), m_buf(s1.rdbuf()), m_s1OrigBuf(s1.rdbuf(&m

Infrequent hangs in a multi-threaded C# console application when using Console.Writeline() or Console.Write()

一世执手 提交于 2020-01-03 08:15:27
问题 I have written a console application that makes use of console.write and console.writeline to provide some logging. The application is a server application that uses asynchronous beginacceptconnection() and beginread() ( Sockets ) for communication. Occasionally i get reports of it hanging and from the limited debug i can do i am able to see the problem being Console.Writeline() or Console.write(). Being multi-threaded I have been careful to have a lock around the logging class so only one

Receiving user input after reading piped input

半腔热情 提交于 2020-01-03 03:22:48
问题 I am writing a small, interactive console application in .NET 4. I want to extend this to be able to handle optional redirected input as well, like: echo hello | myapp.exe Trouble is of course that the redirected input steals the "keyboard stream", so any calls to Console.Read*() returns null. What I have at the moment is: // Read piped input try { bool keyAvailable = Console.KeyAvailable; } catch { string redirected = Console.In.ReadToEnd(); // Need to do something here to "un-redirect"

System.Drawing.DrawString() weird wrapping of long string

回眸只為那壹抹淺笑 提交于 2020-01-03 03:06:08
问题 Update: I would like to answer my own question with code that helped me solve the issue. It was submitted by Bradley but tweaked to work for me and may help others as well. But I can't answer until it is reopened. The linked duplicate provides a method, but no code. A code based answer to this question would be helpful to the community I'm having some slight issues with the formatting of the text drawn on an image inside of my console application. The text I'm trying to draw is: BAS2016=PTR

using getch() to hold command prompt open Visual C++ 2010

强颜欢笑 提交于 2020-01-03 03:02:08
问题 Im currently learning c++ from a book called 'Ivor Hortons Beginning Visual c++ 2010'. In all the examples i've attempted so far I've had to use getch() to hold open the command prompt, and sometimes remove the return 0 statement from the end of the main method. Is this a vagary of windows 7 and will it cause problems further down the line? It's no problem doing this at the moment but since this is not included in the book I was wondering if it might be something I've set up wrong. Many

using getch() to hold command prompt open Visual C++ 2010

若如初见. 提交于 2020-01-03 03:02:05
问题 Im currently learning c++ from a book called 'Ivor Hortons Beginning Visual c++ 2010'. In all the examples i've attempted so far I've had to use getch() to hold open the command prompt, and sometimes remove the return 0 statement from the end of the main method. Is this a vagary of windows 7 and will it cause problems further down the line? It's no problem doing this at the moment but since this is not included in the book I was wondering if it might be something I've set up wrong. Many

Generating .NET Core Console App .exe in Visual Studio 2017

主宰稳场 提交于 2020-01-02 10:29:34
问题 (I am using Visual Studio 2017) I started a small console application (I created a .NET Core application), then I wanted to build the .exe file. But all I get is .dll files and there isn't any .exe file. Can you help me please ? what do I change in Visual Studios settings, to have an .exe file in my correct directory for my console application? 回答1: In fact .NET Core by default generates only dll files that can be run with dotnet : dotnet myapp.dll If you want to publish the app as a self

Why is console animation so slow on Windows? (And is there a way to improve speed?)

三世轮回 提交于 2020-01-01 18:18:23
问题 Well I was bored so wanted to make an animation in a console window. Now when I setup the first bits I noticed it is very slow, something around 333ms for a whole screen to fill with characters.. I am wondering if there is a way to at least get ~20 fps? Here is my code: #include <stdio.h> #include <tchar.h> #include <Windows.h> #include <iostream> #include <array> #define WIDTH (100) #define HEIGHT (35) bool SetWindow(int Width, int Height) { _COORD coord; coord.X = Width; coord.Y = Height;

Why is console animation so slow on Windows? (And is there a way to improve speed?)

天涯浪子 提交于 2020-01-01 18:18:09
问题 Well I was bored so wanted to make an animation in a console window. Now when I setup the first bits I noticed it is very slow, something around 333ms for a whole screen to fill with characters.. I am wondering if there is a way to at least get ~20 fps? Here is my code: #include <stdio.h> #include <tchar.h> #include <Windows.h> #include <iostream> #include <array> #define WIDTH (100) #define HEIGHT (35) bool SetWindow(int Width, int Height) { _COORD coord; coord.X = Width; coord.Y = Height;