November 08, 2017 User input | ||||
---|---|---|---|---|
| ||||
Is there any other way to do a simple user input into integer variables without using std.conv? |
November 08, 2017 Re: User input | ||||
---|---|---|---|---|
| ||||
Posted in reply to Namal | On 11/08/2017 09:19 AM, Namal wrote:
> Is there any other way to do a simple user input into integer variables without using std.conv?
import std.stdio;
void main() {
int i;
readf(" %s", &i); // You can use %d as well
// You can wrap readf in a function template for a more natural use:
int j = read!int();
}
T read(T)()
{
T value;
readf(" %s", &value);
return value;
}
Ali
|
Copyright © 1999-2021 by the D Language Foundation