P
Paul Hemans
Hi I am trying to take input from the console and put it into an integer.
The code below is my attempt, it works, but is there a way that .Parse can
be used without referring to an existing variable (whose value would be
irrelevant anyway).
#include "stdafx.h"
using namespace System;
int main(array<System::String ^> ^args)
{
int width=0;
String^ line;
Console::WriteLine(L"Enter room width\n");
line = Console::ReadLine();
width = width.Parse(line);
Console::WriteLine(L"Pressed \n{0}", width);
return 0;
}
Something like
width = int.Parse(line);
would be nice.
The code below is my attempt, it works, but is there a way that .Parse can
be used without referring to an existing variable (whose value would be
irrelevant anyway).
#include "stdafx.h"
using namespace System;
int main(array<System::String ^> ^args)
{
int width=0;
String^ line;
Console::WriteLine(L"Enter room width\n");
line = Console::ReadLine();
width = width.Parse(line);
Console::WriteLine(L"Pressed \n{0}", width);
return 0;
}
Something like
width = int.Parse(line);
would be nice.