Data conversion

pascal111 judas.the.messiah.111 at gmail.com
Tue Nov 16 19:18:50 UTC 2021


I used "to" keyword which "std.conv" includes for data 
conversions, but I think that there are some other ways for data 
conversions, or maybe there are common ways like casting, I hope 
to know about. For example, next program are using "to":

// D programming language

import std.stdio;
import std.conv;
import std.string;

int main()
{

char[] s;
int x=0, e;


do{

try{
e=1;
write("Enter a numeric value: ");
readln(s);
s=strip(s);
x=to!int(s);}

catch (Exception err){
stderr.writefln!"Warning! %s"(err.msg);
e=0;}

}while(!e);

writeln("Correct numeric value!");

return 0;

}


More information about the Digitalmars-d-learn mailing list