[Issue 2585] std.stream readf
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Thu Jan 15 08:27:48 PST 2009
http://d.puremagic.com/issues/show_bug.cgi?id=2585
------- Comment #1 from fmfrodrigues at gmail.com 2009-01-15 10:27 -------
(In reply to comment #0)
> /*
> I dont know if this is a bug... but its a strange behavior...
> readf documentation:
> abstract int readf(...);
> Scan a string from the input using a similar form to C's scanf and std.format.
> */
>
> /*
> Content of file that is opened:
> 1-2-3-4
> */
>
> /*C sample*/
> #include <stdio.h>
>
>
> int main(int argc, char *argv[])
> {
> FILE *fp = fopen(argv[1],"r");
> int num[4];
> int res = fscanf(fp,"%d-%d-%d-%d",&num[0],&num[1],&num[2],&num[3]);
> printf("\n%d-%d-%d-%d %d",num[0],num[1],num[2],num[3],res);
> fclose(fp);
> return 0;
> }
> /* Output */
> 1-2-3-4 4
>
> /*D sample (dmd 1.034 linux)*/
>
> import std.stdio;
> import std.stream;
>
> int main(string[] args)
> {
> File f = new File(args[1], FileMode.In);
> int num[4];
> TypeInfo[] types = [typeid(int)];
> int res = f.readf("%d-%d-%d-%d",&num[0],&num[1],&num[2],&num[3]);
> printf("\n%d-%d-%d-%d %d",num[0],num[1],num[2],num[3],res);
> f.close();
> return 1;
> }
>
> /* Output */
> 1-2-3-0 3
>
> /* if i put a empty space at end of file content all works fine.*/
>
Sorry... The version of dmd i am using is 1.030 and not 1.034.
--
More information about the Digitalmars-d-bugs
mailing list