How to position the input text cursor in C?

If you are under some Unix terminal (xterm, gnome-terminal …), you can use console codes: #include <stdio.h> #define clear() printf(“\033[H\033[J”) #define gotoxy(x,y) printf(“\033[%d;%dH”, (y), (x)) int main(void) { int number; clear(); printf( “Enter your number in the box below\n” “+—————–+\n” “| |\n” “+—————–+\n” ); gotoxy(2, 3); scanf(“%d”, &number); return 0; } Or using Box-drawing characters: … Read more

Variable format

The syntax you are trying to use is non-standard, it works only in some compilers and I discourage using it. Also, forget the FORMAT() statements for good, they are obsolete. You can get your own number inside the format string when you construct it yourself from several parts character(80) :: form form = ‘( (i10,1x))’ … Read more

CMake output/build directory

It sounds like you want an out of source build. There are a couple of ways you can create an out of source build. Do what you were doing, run cd /path/to/my/build/folder cmake /path/to/my/source/folder which will cause cmake to generate a build tree in /path/to/my/build/folder for the source tree in /path/to/my/source/folder. Once you’ve created it, … Read more

Visual Studio 2012 C++ Standard Output

If your program is linked with /SUBSYSTEM:WINDOWS you will not see the console output unless you allocate a console. Here is code for the allocate console option. With this method you should not need to change your linker settings or create a WinMain. static void OpenConsole() { int outHandle, errHandle, inHandle; FILE *outFile, *errFile, *inFile; … Read more