www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - C's sscanf in D?

reply AEon <aeon2001 lycos.de> writes:
Tried several combinations, and searched for examples but I don't seem 
to be able to get something like C's

   // 59:58 Kill: 0 3 8: pezen killed AEon by MOD_PLASMA
   sscanf(line,"Kill: %d %d %d: ",&pl1,&pl2,&mod);

done in D.


I tried vscanf, but the command does not even seem to exist?
   -> //aepar.d(21): undefined identifier vscanf


I tested scanf:

   char[] line = " 59:58 Kill: 0 3 8: pezen killed AEon by MOD_PLASMA";
   int a,b,c;

   scanf(line, "Kill: %d %d %d: ",a,b,c);

   writefln("59:58 Kill: 0 3 8: (",a,") (",b,")(",c,")");

but that seems to wait for a keyboard input.

Any help appreciated.

AEon
Mar 29 2005
parent =?ISO-8859-1?Q?Anders_F_Bj=F6rklund?= <afb algonet.se> writes:
AEon wrote:

 Tried several combinations, and searched for examples but I don't seem 
 to be able to get something like C's
 
   // 59:58 Kill: 0 3 8: pezen killed AEon by MOD_PLASMA
   sscanf(line,"Kill: %d %d %d: ",&pl1,&pl2,&mod);
 
 done in D.
You need to: a) use sscanf, like above b) wait for "readf" (coming soon) std.string.unformat(line,"Kill: %d %d %d: ",&pl1,&pl2,&mod); // soon --anders
Mar 29 2005