Some questions about porting code from C to BetterC

Bagomot bagomot at gmail.com
Tue Nov 30 19:49:32 UTC 2021


On Tuesday, 30 November 2021 at 19:09:22 UTC, Dennis wrote:
> On Tuesday, 30 November 2021 at 19:07:14 UTC, Bagomot wrote:
>> Hello! Please tell me how to translate this snippet from C in 
>> BetterC:
>> ```c
>> char all[] = "all";
>> char *argv_def[] = { all };
>> if (argc == 0) {
>>     argc = 1;
>>     argv = argv_def;
>> }
>> ```
>
> ```D
> const(char)* all = "all";
> const(char)*[1] argv_def = [all];
> if (argc == 0) {
>     argc = 1;
>     argv = &argv_def;
> }
> ```

I get an error with this code:
```text
Error: cannot implicitly convert expression & argv_def of type 
const(char)*[1]* to char**
```


More information about the Digitalmars-d mailing list