By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,652 Members | 1,358 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,652 IT Pros & Developers. It's quick & easy.

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

P: n/a
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* i = Console::ReadLine();

Can anybody tell me how can I do this:

int i = Console::Readline();
Jun 29 '07 #1
Share this Question
Share on Google+
1 Reply


P: n/a
* Allen Maki wrote, On 29-6-2007 23:32:
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* i = Console::ReadLine();

Can anybody tell me how can I do this:

int i = 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
Jun 29 '07 #2

This discussion thread is closed

Replies have been disabled for this discussion.