char* vs char[]
jicman
jicman at mail.com
Sat Dec 16 20:03:29 PST 2006
Feliz Navidad.
I have not being reading the newsgroups, because of a few projects
that I have going on. I am trying to get D into my company. It's
not going to be easy, but I am positive. :-)
So I have this module that gets some environment variables from the
system. Here is some code:
//-------------------------------------------------------
extern (C)
{
char* getenv (char *);
int putenv (char *);
}
char[] GetEnv(char[] pSymbol)
{
return std.string.toString(getenv(pSymbol));
}
int PutEnv(char[] eVar, char[] eVal)
{
int i = putenv(eVar ~ "=" ~ eVal);
return i;
}
char[] GetServerName()
{
// returns the Hostname on the local computer
char[] sn = GetEnv("COMPUTERNAME");
return sn;
}
//-------------------------------------------------------
I copied it from the group a few years ago. So, now, with this
new .177 release I get this new error:
..\jic\libs\MyOSEnv.d(32): function jic.libs.MyOSEnv.getenv (char*)
does not match parameter types (char[])
..\jic\libs\MyOSEnv.d(32): Error: cannot implicitly convert
expression (pSymbol) of type char[] to char*
..\jic\libs\MyOSEnv.d(37): function jic.libs.MyOSEnv.putenv (char*)
does not match parameter types (char[])
..\jic\libs\MyOSEnv.d(37): Error: cannot implicitly convert
expression ((eVar) ~ "=" ~ (eVal)) of type char[] to char*
How can I fix this? Will someone be willing to point me on the
right direction?
Thanks,
josé
More information about the Digitalmars-d-learn
mailing list