fork download
  1. #include "stdafx.h"
  2. bool SetWindow(int Width, int Height);
  3.  
  4. unsigned char Screen[100][35];
  5.  
  6. int _tmain(int argc, _TCHAR* argv[])
  7. {
  8. std::fill(&Screen,&Screen+sizeof(unsigned char)*100*35,219);
  9. if(SetWindow(100,35))
  10. {
  11. std::cout<<" success changing screen..." << std::endl;
  12. Sleep(1000);
  13. std::cout<<" Loading components..." << std::endl;
  14. for(int i = 0; i < 100; ++i)
  15. {
  16. Sleep(50);
  17. std::cout << static_cast<unsigned char>(219);
  18. }
  19. std::cout << std::endl;
  20. Sleep(500);
  21. std::cout<<" ...done" << std::endl;
  22. system("CLS");
  23. std::cout<< Screen;
  24. }
  25. while(GetAsyncKeyState(VK_ESCAPE) == 0)
  26. {
  27.  
  28. }
  29. return 0;
  30. }
  31.  
  32. bool SetWindow(int Width, int Height)
  33. {
  34. _COORD coord;
  35. coord.X = Width;
  36. coord.Y = Height;
  37.  
  38. _SMALL_RECT Rect;
  39. Rect.Top = 0;
  40. Rect.Left = 0;
  41. Rect.Bottom = Height - 1;
  42. Rect.Right = Width - 1;
  43.  
  44. // Get handle of the standard output
  45. HANDLE Handle = GetStdHandle(STD_OUTPUT_HANDLE);
  46. if (Handle == NULL)
  47. {
  48. std::cout<<"Failure in getting the handle\n"<<GetLastError();
  49. return FALSE;
  50. }
  51.  
  52. // Set screen buffer size to that specified in coord
  53. if(!SetConsoleScreenBufferSize(Handle, coord))
  54. {
  55. //std::cout<<"Failure in setting buffer size\n"<<GetLastError();
  56. //return FALSE;
  57. }
  58.  
  59. // Set the window size to that specified in Rect
  60. if(!SetConsoleWindowInfo(Handle, TRUE, &Rect))
  61. {
  62. std::cout<<"Failure in setting window size\n"<<GetLastError();
  63. return FALSE;
  64. }
  65.  
  66. return TRUE;
  67. }
  68.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp:1:20: error: stdafx.h: No such file or directory
prog.cpp:6: error: ‘_TCHAR’ has not been declared
prog.cpp: In function ‘int _tmain(int, int**)’:
prog.cpp:8: error: ‘fill’ is not a member of ‘std’
prog.cpp:11: error: ‘cout’ is not a member of ‘std’
prog.cpp:11: error: ‘endl’ is not a member of ‘std’
prog.cpp:12: error: ‘Sleep’ was not declared in this scope
prog.cpp:13: error: ‘cout’ is not a member of ‘std’
prog.cpp:13: error: ‘endl’ is not a member of ‘std’
prog.cpp:17: error: ‘cout’ is not a member of ‘std’
prog.cpp:19: error: ‘cout’ is not a member of ‘std’
prog.cpp:19: error: ‘endl’ is not a member of ‘std’
prog.cpp:21: error: ‘cout’ is not a member of ‘std’
prog.cpp:21: error: ‘endl’ is not a member of ‘std’
prog.cpp:22: error: ‘system’ was not declared in this scope
prog.cpp:23: error: ‘cout’ is not a member of ‘std’
prog.cpp:25: error: ‘VK_ESCAPE’ was not declared in this scope
prog.cpp:25: error: ‘GetAsyncKeyState’ was not declared in this scope
prog.cpp: In function ‘bool SetWindow(int, int)’:
prog.cpp:34: error: ‘_COORD’ was not declared in this scope
prog.cpp:34: error: expected `;' before ‘coord’
prog.cpp:35: error: ‘coord’ was not declared in this scope
prog.cpp:38: error: ‘_SMALL_RECT’ was not declared in this scope
prog.cpp:38: error: expected `;' before ‘Rect’
prog.cpp:39: error: ‘Rect’ was not declared in this scope
prog.cpp:45: error: ‘HANDLE’ was not declared in this scope
prog.cpp:45: error: expected `;' before ‘Handle’
prog.cpp:46: error: ‘Handle’ was not declared in this scope
prog.cpp:46: error: ‘NULL’ was not declared in this scope
prog.cpp:48: error: ‘cout’ is not a member of ‘std’
prog.cpp:48: error: ‘GetLastError’ was not declared in this scope
prog.cpp:49: error: ‘FALSE’ was not declared in this scope
prog.cpp:53: error: ‘Handle’ was not declared in this scope
prog.cpp:53: error: ‘SetConsoleScreenBufferSize’ was not declared in this scope
prog.cpp:60: error: ‘Handle’ was not declared in this scope
prog.cpp:60: error: ‘TRUE’ was not declared in this scope
prog.cpp:60: error: ‘SetConsoleWindowInfo’ was not declared in this scope
prog.cpp:62: error: ‘cout’ is not a member of ‘std’
prog.cpp:62: error: ‘GetLastError’ was not declared in this scope
prog.cpp:63: error: ‘FALSE’ was not declared in this scope
prog.cpp:66: error: ‘TRUE’ was not declared in this scope
stdout
Standard output is empty