digitalmars.D - Command Line Input
- Shom (7/7) May 11 2005 Hi Everyone,
- Hasan Aljudy (6/19) May 11 2005 I'm new myself.
- =?ISO-8859-1?Q?Anders_F_Bj=F6rklund?= (7/20) May 12 2005 You mean std.stdio.readf, which hasn't been added to DMD just yet...
- John Reimer (11/38) May 12 2005 Indeed. Check Mango out. :-)
- =?ISO-8859-1?Q?Anders_F_Bj=F6rklund?= (12/21) May 12 2005 variadic inout is not allowed ? Besides, using pointers make it
- =?ISO-8859-1?Q?Anders_F_Bj=F6rklund?= (4/8) May 12 2005 Maybe I forgot to mention it, but Mango doesn't work on Mac OS X (yet).
- SeeSchloss (7/12) May 12 2005 Hmm, well I'm not sure how cin >> works, but std.stream.stdin.readLine (...
- Ben Hinkle (10/28) May 12 2005 That should work. For example
- SeeSchloss (6/19) May 12 2005 Yeah, that's what I mean.
- Ben Hinkle (4/26) May 12 2005 I agree it's annoying to have std.stdio and std.stream conflict. Maybe
Hi Everyone, I just started messing around with D... and it totally kicks butt! However, is there any easy way for command line input? I mean something simple like the good old C/C++ cin >> I would appreciate any help with this. Thanks, Shom
May 11 2005
Shom wrote:Hi Everyone, I just started messing around with D... and it totally kicks butt! However, is there any easy way for command line input? I mean something simple like the good old C/C++ cin >> I would appreciate any help with this. Thanks, ShomI'm new myself. cin >> is a C++ thing, for now, D is stuck with the old C way, which is scanf(...); It would be nice if there was a cleaner way to do this (someone could write some sort of a wrapper?)
May 11 2005
Hasan Aljudy wrote:You mean std.stdio.readf, which hasn't been added to DMD just yet... ("readf" is to "writef", what "scanf" is to "printf". i.e. the D way) See http://www.digitalmars.com/drn-bin/wwwnews?digitalmars.D/21692 You should also check out the Mango Tree, which has stream classes. (unfortunately Dsource is down at the moment, but when it comes back) --andersI just started messing around with D... and it totally kicks butt! However, is there any easy way for command line input? I mean something simple like the good old C/C++ cin >> I would appreciate any help with this.I'm new myself. cin >> is a C++ thing, for now, D is stuck with the old C way, which is scanf(...); It would be nice if there was a cleaner way to do this (someone could write some sort of a wrapper?)
May 12 2005
Anders F Björklund wrote:Hasan Aljudy wrote:Indeed. Check Mango out. :-) Anders, Just looking at your example in your news link above: read(&name); // without format readf("%s", &name); // with format I was curious to know why you chose to use the "address of" operator here. Wouldn't it be better to use d's inout reference instead? That ampersand is just as unattractive now in D as it has been in C for all these years. I could be missing something, though. -JJRYou mean std.stdio.readf, which hasn't been added to DMD just yet... ("readf" is to "writef", what "scanf" is to "printf". i.e. the D way) See http://www.digitalmars.com/drn-bin/wwwnews?digitalmars.D/21692 You should also check out the Mango Tree, which has stream classes. (unfortunately Dsource is down at the moment, but when it comes back) --andersI just started messing around with D... and it totally kicks butt! However, is there any easy way for command line input? I mean something simple like the good old C/C++ cin >> I would appreciate any help with this.I'm new myself. cin >> is a C++ thing, for now, D is stuck with the old C way, which is scanf(...); It would be nice if there was a cleaner way to do this (someone could write some sort of a wrapper?)
May 12 2005
John Reimer wrote:Just looking at your example in your news link above: read(&name); // without format readf("%s", &name); // with format I was curious to know why you chose to use the "address of" operator here. Wouldn't it be better to use d's inout reference instead? That ampersand is just as unattractive now in D as it has been in C for all these years. I could be missing something, though.variadic inout is not allowed ? Besides, using pointers make it easier to separate the format strings and the string receptors... (since there is no "const char *" and "char *" distinction in D) Unfortunately it doesn't work very good, since TypeInfo for pointers is not implemented yet. So it relies on some horrible workarounds now. But when typeid for pointers works, it's simple to remove those... readf is just intended as a improvement over scanf. Not a cure-all ? (besides it seemed silly to have a "stdio" that only did O and not I) Just as writef is an improvement over printf, but still somewhat ugly. (but I think my new write/writeln addition fixes that, to some degree) --anders
May 12 2005
John Reimer wrote:Maybe I forgot to mention it, but Mango doesn't work on Mac OS X (yet). Whileas scanf and readf (with some workarounds) do. That's it, for me. --andersYou should also check out the Mango Tree, which has stream classes. (unfortunately Dsource is down at the moment, but when it comes back)Indeed. Check Mango out. :-)
May 12 2005
In article <d5uspi$2gsg$1 digitaldaemon.com>, Shom says...Hi Everyone, I just started messing around with D... and it totally kicks butt! However, is there any easy way for command line input? I mean something simple like the good old C/C++ cin >> I would appreciate any help with this.Hmm, well I'm not sure how cin >> works, but std.stream.stdin.readLine () is nice for reading stdin. BTW, it'd be nice if importing std.stream didn't import some other std.c.<something ?> package which already defines std{in,out,err} as it requires to make an alias if one wants to simply use "stdin" instead of "std.stream.stdin".
May 12 2005
"SeeSchloss" <SeeSchloss_member pathlink.com> wrote in message news:d5v8mi$2u6a$1 digitaldaemon.com...In article <d5uspi$2gsg$1 digitaldaemon.com>, Shom says...That should work. For example import std.stream; int main() { char[] line = stdin.readLine(); stdout.writefln("%s",line); return 0; } Is that what you mean?Hi Everyone, I just started messing around with D... and it totally kicks butt! However, is there any easy way for command line input? I mean something simple like the good old C/C++ cin >> I would appreciate any help with this.Hmm, well I'm not sure how cin >> works, but std.stream.stdin.readLine () is nice for reading stdin. BTW, it'd be nice if importing std.stream didn't import some other std.c.<something ?> package which already defines std{in,out,err} as it requires to make an alias if one wants to simply use "stdin" instead of "std.stream.stdin".
May 12 2005
Yeah, that's what I mean. And... ok I was just wrong, it's importing both std.stream and std.stdio, which creates a conflict. I guess I never imported std.stream without std.stdio, and since it happened just when adding the std.stream import, I never looked anywhere else. *hides in shame*BTW, it'd be nice if importing std.stream didn't import some other std.c.<something ?> package which already defines std{in,out,err} as it requires to make an alias if one wants to simply use "stdin" instead of "std.stream.stdin".That should work. For example import std.stream; int main() { char[] line = stdin.readLine(); stdout.writefln("%s",line); return 0; } Is that what you mean?
May 12 2005
"SeeSchloss" <SeeSchloss_member pathlink.com> wrote in message news:d5vt5l$emj$1 digitaldaemon.com...I agree it's annoying to have std.stdio and std.stream conflict. Maybe std.stream.stdin and friends need a rename...Yeah, that's what I mean. And... ok I was just wrong, it's importing both std.stream and std.stdio, which creates a conflict. I guess I never imported std.stream without std.stdio, and since it happened just when adding the std.stream import, I never looked anywhere else. *hides in shame*BTW, it'd be nice if importing std.stream didn't import some other std.c.<something ?> package which already defines std{in,out,err} as it requires to make an alias if one wants to simply use "stdin" instead of "std.stream.stdin".That should work. For example import std.stream; int main() { char[] line = stdin.readLine(); stdout.writefln("%s",line); return 0; } Is that what you mean?
May 12 2005