This question already has answers here:
Getting terminal width in C?
(8 answers)
Closed 7 years ago.
I have a few general questions about writing C++ programs and running them from Unix shells. Is there a way to ask the shell for it's size? Either in pixels, characters, whatever? What about relocating the cursor within the window? How would you do this if you needed to?
With the ncurses library, getting the terminal width (in characters) is as easy as calling the function getmaxx. Similarly, getmaxy returns the height, and getmaxyx gets them both at once.
The cursor can be moved by calling move with the x and y coordinates.
Check NCURSES it is what I think you are looking for.
Related
This question already has answers here:
How do I input variables using cin without creating a new line?
(7 answers)
Closed 7 years ago.
in my Windows Console application I have to read characters from stdin without waiting for newline (press Entrer).
I tried out get, getchar and tons of other solutions, but this question still open for me. Can anybody help me, how I can reach it?
It's _getch (or _getche if you want character echoing). Include <conio.h>.
This question already has answers here:
C++ cache aware programming
(10 answers)
Closed 7 years ago.
I am profiling my code on various CPUs running Windows7 and my results so far suggest that I need to tune a buffer size proportional to the machine's L2CacheSize or L3CacheSize. Is there a way to obtain these parameters from C++?
You can use the GetLogicalProcessorInformation function to get that. It returns an array of SYSTEM_LOGICAL_PROCESSOR_INFORMATION structures which contain a CACHE_DESCRIPTOR structure, which provides the cache size information.
This question already has answers here:
How to detect reliably Mac OS X, iOS, Linux, Windows in C preprocessor? [duplicate]
(3 answers)
Closed 8 years ago.
It's been 10 years since I've learned C++ during high school, now I'm playing around it again and I'll already facing some problems regarding multi-platform.
I saw that if I want to display special characters on windows, I should use wprintf. However, on *nix systems, it is not necessary.
So, how can I detect what is the current platform, so I can run printf or wprintf depending on it?
UPDATE
I'll open a new question with the error and close this one.
You could simply use wprintf (or wcout <<) on either platform. See this question for an example.
This question already has answers here:
C++ standard output format
(2 answers)
Closed 10 years ago.
I'm still new to C++ so bear with me.
I'm currently making console output applications and I want to make a simple matrix calculator. So I want the user to input 4 values for each element of the matrix. Each element should be at a different xy position on the screen. So it makes up a square, a simple 2x2 matrix.
I don't have a clue how to change the position of text in C++ though. I used the Pascal programming languages before and all you had to do was 'gotoXY(20,40)' followed by a statement.
I know this is probably an easy question, I can't seem to work it out though.
If this is on Windows, you should use SetConsoleCursorPosition. I think I have the right helper class for you here: Helper Class for Console Functions.
This question already has answers here:
Closed 11 years ago.
Possible Duplicates:
“APIENTRY _tWinMain” and “WINAPI WinMain” difference
What functions does _WinMainCRTStartup perform?
I just started to dive into windows programming. And when I tried to understand the win 32 program I noticed that the program has two entry points which are _tmainCRTStartup and _WinMainCRTStartup. Besides, I found the _tmainCRTStartup function also called _WinMain function. I just wonder what are they used for? And why there are two different entry points.
Thanks!