Biggest problems w/ D

Paul Findlay r.lph50+d at gmail.com
Fri Aug 10 06:11:21 PDT 2007


Umm can we review what you are tying to do.. because if its something like
this (C version)

#include <stdio.h>

void GetName(char *name)
{
        name = "The right one";
}

int main()
{
        char *name = "the original";
        GetName(name);
        printf("%s\n", name);
}

it will print: the original

If you want name to hold "the right one" it will need to be a pointer to a
pointer:

#include <stdio.h>

void GetName(char **name)
{
        *name = "The right one";
}

int main()
{
        char *name = "the original";
        GetName(&name);
        printf("%s\n", name);
        // will print: The right one
}

Otherwise, I give up..



More information about the Digitalmars-d mailing list