type conversions
Andrej Mitrovic
andrej.mitrovich at gmail.com
Sun Apr 29 17:21:26 PDT 2012
On 4/30/12, WhatMeWorry <kc_heaser at yahoo.com> wrote:
> I'm trying to get my head around D's type conversion. What is the
> best way to convert a string to a char array? Or I should say is
> this the best way?
>
> string s = "Hello There";
> char[] c;
>
> c = string.dup;
>
Well it depends . Why do you need a char[]? If you're interfacing with
C you most likely need a 0-terminated string and not a char[].
> Also, what is the best way to explicitly convert a string to an
> int?
import std.conv;
int i = to!int("12345");
More information about the Digitalmars-d-learn
mailing list