fork(3) download
  1. #include <windows.h> //header file for windows
  2. #include <stdio.h>
  3.  
  4. void ClearConsoleToColors(int ForgC, int BackC);
  5. int main()
  6. {
  7. ClearConsoleToColors(7,34);
  8. Sleep(1000);
  9. printf("Agan");
  10. return 0;
  11. }
  12. void ClearConsoleToColors(int ForgC, int BackC)
  13. {
  14. WORD wColor = ((BackC & 0x0F) << 4) + (ForgC & 0x0F);
  15. //Get the handle to the current output buffer...
  16. HANDLE hStdOut = GetStdHandle(STD_OUTPUT_HANDLE);
  17. //This is used to reset the carat/cursor to the top left.
  18. COORD coord = {0, 0};
  19. //A return value... indicating how many chars were written
  20. // not used but we need to capture this since it will be
  21. // written anyway (passing NULL causes an access violation).
  22. DWORD count;
  23.  
  24. //This is a structure containing all of the console info
  25. // it is used here to find the size of the console.
  26. CONSOLE_SCREEN_BUFFER_INFO csbi;
  27. //Here we will set the current color
  28. SetConsoleTextAttribute(hStdOut, wColor);
  29. if(GetConsoleScreenBufferInfo(hStdOut, &csbi))
  30. {
  31. //This fills the buffer with a given character (in this case 32=space).
  32. FillConsoleOutputCharacter(hStdOut, (TCHAR) 32, csbi.dwSize.X * csbi.dwSize.Y, coord, &count);
  33.  
  34. FillConsoleOutputAttribute(hStdOut, csbi.wAttributes, csbi.dwSize.X * csbi.dwSize.Y, coord, &count );
  35. //This will set our cursor position for the next print statement.
  36. SetConsoleCursorPosition(hStdOut, coord);
  37. }
  38. return 0;
  39. }
  40.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.c:1:56: error: windows.h: No such file or directory
prog.c: In function ‘main’:
prog.c:8: warning: implicit declaration of function ‘Sleep’
prog.c: In function ‘ClearConsoleToColors’:
prog.c:14: error: ‘WORD’ undeclared (first use in this function)
prog.c:14: error: (Each undeclared identifier is reported only once
prog.c:14: error: for each function it appears in.)
prog.c:14: error: expected ‘;’ before ‘wColor’
prog.c:16: error: ‘HANDLE’ undeclared (first use in this function)
prog.c:16: error: expected ‘;’ before ‘hStdOut’
prog.c:18: error: ‘COORD’ undeclared (first use in this function)
prog.c:18: error: expected ‘;’ before ‘coord’
prog.c:22: error: ‘DWORD’ undeclared (first use in this function)
prog.c:22: error: expected ‘;’ before ‘count’
prog.c:26: error: ‘CONSOLE_SCREEN_BUFFER_INFO’ undeclared (first use in this function)
prog.c:26: error: expected ‘;’ before ‘csbi’
prog.c:28: warning: implicit declaration of function ‘SetConsoleTextAttribute’
prog.c:28: error: ‘hStdOut’ undeclared (first use in this function)
prog.c:28: error: ‘wColor’ undeclared (first use in this function)
prog.c:29: warning: implicit declaration of function ‘GetConsoleScreenBufferInfo’
prog.c:29: error: ‘csbi’ undeclared (first use in this function)
prog.c:32: warning: implicit declaration of function ‘FillConsoleOutputCharacter’
prog.c:32: error: ‘TCHAR’ undeclared (first use in this function)
prog.c:32: error: expected ‘)’ before numeric constant
prog.c:34: warning: implicit declaration of function ‘FillConsoleOutputAttribute’
prog.c:34: error: ‘coord’ undeclared (first use in this function)
prog.c:34: error: ‘count’ undeclared (first use in this function)
prog.c:36: warning: implicit declaration of function ‘SetConsoleCursorPosition’
prog.c:38: warning: ‘return’ with a value, in function returning void
stdout
Standard output is empty