sscanf() equivalent for D using Phobos library?
    BCS 
    ao at pathlink.com
       
    Wed Dec  3 16:04:45 PST 2008
    
    
  
Reply to rocknroll714,
> Hi. I discovered D recently and I am very, very impressed. I've
> decided to switch from C/C++ over to D as my programming language of
> choice. Right now I'm porting one of my C++ applications to D, and I
> need some help with a simple conversion.
> 
> How would I do this:
> 
> if(sscanf(line, "%[^:]: %[^\r\n]", name, value) != 2) {...}
> 
> In D? I'm looping through a text file using the File.getline() command
> and splitting each line into two separate variables with the sscanf
> command. The if conditional check is to make sure the line is
> formatted properly (the text file is the settings file for my
> application).
> 
> Help please!
> 
the quick and wrong way that works is to go find std.c.stdio and call the 
C sscanf function. (be sure to uses toStringz on the line arg and to allocate 
for the outputs as you would in c
as for a native D equivalent... I'm not sure.
    
    
More information about the Digitalmars-d-learn
mailing list