c++ - "Console:: " do not compile -
this code taken http://msdn.microsoft.com/en-us/library/system.console.windowwidth.aspx want compile in gcc compiler.
#include<cstdio> #include<string> #include<windows.h> #include<iostream> using namespace system; int main() { int origwidth; int width; int origheight; int height; string^ m1 = "the current window width {0}, , " "current window height {1}."; string^ m2 = "the new window width {0}, , new " "window height {1}."; string^ m4 = " (press key continue...)"; // // step 1: current window dimensions. // origwidth = console::windowwidth; origheight = console::windowheight; console::writeline( m1, console::windowwidth, console::windowheight ); console::writeline( m4 ); console::readkey( true ); // // step 2: cut window 1/4 original size. // width = origwidth / 2; height = origheight / 2; console::setwindowsize( width, height ); console::writeline( m2, console::windowwidth, console::windowheight ); console::writeline( m4 ); console::readkey( true ); // // step 3: restore window original size. // console::setwindowsize( origwidth, origheight ); console::writeline( m1, console::windowwidth, console::windowheight ); }
but shows error.
the error is
f:\untitled2.cpp||in function 'int main()':| f:\untitled2.cpp|31|error: 'console' has not been declared| f:\untitled2.cpp|32|error: 'console' has not been declared| f:\untitled2.cpp|33|error: 'console' has not been declared| f:\untitled2.cpp|34|error: 'console' has not been declared| f:\untitled2.cpp|35|error: 'console' has not been declared| f:\untitled2.cpp|35|error: 'name' not declared in scope| f:\untitled2.cpp|36|error: 'console' has not been declared| ||=== build finished: 7 errors, 0 warnings (0 minutes, 0 seconds) ===|
what should need add code?
that code not c++, c++/cli. use microsoft compiler it.
Comments
Post a Comment