Skip to content

Instantly share code, notes, and snippets.

@MoSal
Created October 9, 2015 23:07
Show Gist options
  • Save MoSal/af351add0efee1a8ccf7 to your computer and use it in GitHub Desktop.
Save MoSal/af351add0efee1a8ccf7 to your computer and use it in GitHub Desktop.
#include <unistd.h>
#include <stdio.h>
#include <windows.h>
int main() {
printf("isatty(fileno(stdout)) returned %d\n", isatty(fileno(stdout)));
printf("_isatty(fileno(stdout)) returned %d\n", _isatty(fileno(stdout)));
HANDLE h = GetStdHandle(STD_OUTPUT_HANDLE);
if (h == INVALID_HANDLE_VALUE) {
printf("GetStdHandle(STD_OUTPUT_HANDLE) failed.\n");
return -2;
}
CONSOLE_SCREEN_BUFFER_INFO INFO;
if ( !GetConsoleScreenBufferInfo(h, &INFO) ) {
printf("GetConsoleScreenBufferInfo() failed.\n");
return -1;
}
printf("cols=%d\n", (int)INFO.dwSize.X);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment