现学现用
程序代码:
#include "stdafx.h" #include <iostream> using namespace System; int main(array<System::String ^> ^args) { Console::WriteLine(L"Enter please a sentence: "); String^ line = Console::ReadLine(); //读取输入的字符串 Console::WriteLine(L"Enter please a letter: "); char ch = Console::Read(); //读取输入的单个字符 Console::WriteLine(L"Your sentence is :{0}",line); Console::Write(L"Your letter is: {0}",ch); Console::Write(L"\nPress any key,please:"); ConsoleKeyInfo keyPress = Console::ReadKey(true); //读取所按的键 Console::WriteLine(L"\nThe key press corresponds to the character: {0}",keyPress.KeyChar);//输出上一句按的键的信息 system("pause"); return 0; }