How can I make Console::ReadLine accepts int? In other words.

  • Thread starter Thread starter Allen Maki
  • Start date Start date
A

Allen Maki

Hi everybody,

I need your help.

I am using Visual C++ .NET

How can I make Console::ReadLine accepts int? In other words.

I know I can do this:

string* = Console::ReadLine();

Can anybody tell me how can I do this:

int = Console::Readline();
 
* Allen Maki wrote, On 29-6-2007 23:30:
Hi everybody,

I need your help.

I am using Visual C++ .NET

How can I make Console::ReadLine accepts int? In other words.

I know I can do this:

string* = Console::ReadLine();

Can anybody tell me how can I do this:

int = Console::Readline();

In C# it would be something like this:

string i = Console.ReadLine();
int ii = -1;
if ( int32.TryParse(i, NumberStyles.Integer, out ii) )
{
// do stuff with ii
}
else
{
// print error?
}


It shouldn't be hard to convert that to c++ I guess.

Jesse

PS: Please, do not double post (one message for every group), but if you
absolutely need to post in different newsgroups at the same time, cross
post (address one message to multiple groups at once). That way answers
given in the other groups will automatically show up here as well.
 
Back
Top