How can I convert the following C to D.

anon via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Wed Jan 21 16:07:48 PST 2015


On Wednesday, 21 January 2015 at 23:59:34 UTC, ketmar via 
Digitalmars-d-learn wrote:
> On Wed, 21 Jan 2015 23:50:59 +0000
> anon via Digitalmars-d-learn 
> <digitalmars-d-learn at puremagic.com> wrote:
>
>> On Wednesday, 21 January 2015 at 23:47:46 UTC, ketmar via 
>> Digitalmars-d-learn wrote:
>> > On Wed, 21 Jan 2015 23:44:49 +0000
>> > anon via Digitalmars-d-learn 
>> > <digitalmars-d-learn at puremagic.com> wrote:
>> >
>> >> I have the following C code, how can I do the same in D.
>> >> 
>> >> Info **info;
>> >> info = new Info*[hl + 2];
>> >> 
>> >> int r;
>> >> for(r = 0; r < hl; r++)
>> >> {
>> >> 	info[r] = new Info[vl + 2];
>> >> }
>> >> info[r] = NULL;
>> >> 
>> >> anon
>> > this is not C.
>> 
>> Your right its c++
> so the answer to your question is very easy: just type in any
> gibberish. as C cannot compile C++ code, the final result is to 
> get the
> code that cannot be compiled. any gibberish will do.

Great answer.

Anyway the code isn't mine I just wanted to know how to handle 
what the author wrote.

I got it working with.

auto info = new Info[][](hl, vl);

and changing the logic so as not check for the NULL.

No need on being picky it was just a question.

anon


More information about the Digitalmars-d-learn mailing list