Download Reference Manual
The Developer's Library for D
About Wiki Forums Source Search Contact

Integer input?

Moderators: larsivi kris

Posted: 09/10/08 15:22:07

Well, this is a very stupid problem, as I was getting my head around Tango. I'm not at my computer, so I can't test.

It seems that Cin' from Console' does not accept integers? I was kinda thinking I could use it like `std::cin' in C++, where I just can have simple integer input.

Author Message

Posted: 09/10/08 15:26:34 -- Modified: 09/10/08 15:30:59 by
Cyborg16

Err... should have properly read that before posting (I just posted to use Stdout).

I know there's some new stream stuff, but I haven't used it. You could try looking what Console.Input.stream gives you. Can't really help any more.

Posted: 09/10/08 17:07:37 -- Modified: 09/10/08 17:46:54 by
LXXXIII -- Modified 2 Times

I've looked, but it doesn't seem like that part of Console will help me. I suppose I could just use scanf from the ol' C. Of course, that means I have to type in another extra import. D/Tango is not behaving like I expect it to, but I guess I gotta get used to it some more.

~edit: So it seems I am to import tango.io.Console for string input, tango.io.Stdout for output (because it's better than Cout), and tango.stdc.stdio for integer input with scanf. That's a lot o' imports for basic console commands. Just thought I'd mention that. Or am I missing something?

Posted: 09/10/08 18:25:45

Tango doesn't currently have formatted input. Your best bet is to read text using Cin and then use tango.text.convert.Integer to parse the integers.

Posted: 09/10/08 19:53:56

That module name is too long to remember comfortably and I don't wanna type all of that. And I don't feel like having to convert a string to get integers. I think I will just use scanf for it.

But I'm thinking. Would it take much effort to make such an ability for Tango, to have formatted input? I was just having some rough ideas for it.

Cool icon, btw, schveiguy, hehe.