Some questions about porting code from C to BetterC
Dennis
dkorpel at gmail.com
Tue Nov 30 19:59:28 UTC 2021
On Tuesday, 30 November 2021 at 19:49:32 UTC, Bagomot wrote:
> I get an error with this code:
> ```text
> Error: cannot implicitly convert expression & argv_def of type
> const(char)*[1]* to char**
> ```
Sorry, should be:
```D
const(char)* all = "all";
const(char)*[1] argv_def = [all];
if (argc == 0) {
argc = 1;
argv = argv_def.ptr; // <-- .ptr instead of &argv_def
}
```
.ptr gives a pointer to the first element of the static array,
which is what arrays implicitly convert to in C. From your error
message I gather the type of `argv` is `char**`. Since you assign
it a string literal, you should make it `const(char)**`.
More information about the Digitalmars-d
mailing list