- 论坛徽章:
- 0
|
别搞了,白费力气,二楼的代码是在linux下才可以成功的,windows不行;
这是网上的一段代码,但是编译有些问题:
- #include <stdio.h>
- #include <stdlib.h>
- #include <windows.h>
- int main(int argc, char *argv[])
- {
- HANDLE hStdout = GetStdHandle(STD_OUTPUT_HANDLE);
- if (hStdout=INVALID_HANDLE_VALUE) return 0;
- CONSOLE_SCREEN_BUFFER_INFO csbinInfo;
- if (! GetConsoleScreenBufferInfo(hStdout, &csbiInfo))
- {
- MessageBox(Null, "GetConsoleScreenBufferInfo", "Console Error", MB_OK);
- return -1;
- }
- SetConsoleTextAttribute(hStdout,2);
- printf("i feel you!");
- SetConsoleTextAttribute(hStdout,2|4|8|16);
- printf("you ?");
- SetConsoleTextAttribute(hStdout, csbinInfo.wAttribute);
- getchar();
- return 0;
- }
复制代码Compiler: Default compiler
Executing g++.exe...
g++.exe "d:\Documents_and_Settings\plp2\desktop\Untitled1.cpp" -o "d:\Documents_and_Settings\plp2\desktop\Untitled1.exe" -I"C:\Program Files\Dev-Cpp\include\c++\3.3.1" -I"C:\Program Files\Dev-Cpp\include\c++\3.3.1\mingw32" -I"C:\Program Files\Dev-Cpp\include\c++\3.3.1\backward" -I"C:\Program Files\Dev-Cpp\lib\gcc-lib\mingw32\3.3.1\include" -I"C:\Program Files\Dev-Cpp\include" -L"C:\Program Files\Dev-Cpp\lib"
d:/Documents_and_Settings/plp2/desktop/Untitled1.cpp: In function `int
main(int, char**)':
d:/Documents_and_Settings/plp2/desktop/Untitled1.cpp:11: error: `csbiInfo'
undeclared (first use this function)
d:/Documents_and_Settings/plp2/desktop/Untitled1.cpp:11: error: (Each
undeclared identifier is reported only once for each function it appears
in.)
d:/Documents_and_Settings/plp2/desktop/Untitled1.cpp:13: error: `Null'
undeclared (first use this function)
d:/Documents_and_Settings/plp2/desktop/Untitled1.cpp:22: error: 'struct
CONSOLE_SCREEN_BUFFER_INFO' has no member named 'wAttribute'
Execution terminated |
|