我如何TryParse用户输入?

时间:2014-04-23 10:01:10

标签: c++-cli

这是我的问题:

#include "stdafx.h"
#include <iostream>
#include <string>
#define newline '\n'
using namespace std;
using namespace System;

int _tmain(int argc, _TCHAR* argv[])
{
bool isNumber;
String^ age;
Int32 result;
cout
    << "Please enter your age:"
    << newline;
cin >> age;
isNumber = Int32::TryParse(age, result);
return 0;
}

我不能使用带有String的cin ^我不能使用字符串来tryparse

0 个答案:

没有答案