On Thursday, 4 June 2015 at 21:35:40 UTC, Kyoji Klyden wrote:
On Thursday, 4 June 2015 at 03:25:24 UTC, ketmar wrote:
On Wed, 03 Jun 2015 11:59:56 +0000, Kyoji Klyden wrote:

[...]
what
exactly is char**? Is it pointing to the first char of the first string
in an array?

it's a pointer to array of pointers to first chars of strings. ;-)

Ohh okay. So this is how the function is able to take multiple strings then.. How was I supposed to know it was an array though? Is it because it was a string type pointer?

Generally, a `char**` is a pointer to a pointer to a char. There may be more pointers to chars behind the pointed-to one. And there may be more chars behind the pointed-to ones. You can't know just from the type. You have to read the documentation of the involved functions for the specifics.

Also does D primarily use explicit length field strings?

I'm not sure if I understand you right, but yes, D arrays carry their length. And D `string`s are arrays. You should encounter things like `char**` pretty much only when talking to C code.

By the way, there are subtly different meanings of "array" and "string" which I hope you're aware of, but just to be sure: "array" can refer to D array types, i.e. a pointer-length pair, e.g. char[]. Or it can refer to the general concept of a contiguous sequence of elements in memory. And as a special case, "string" can refer to D's `string` type, which is an alias for `immutable(char)[]`. Or it can refer to a contiguous sequence of characters in memory. And when ketmar writes: "it's a pointer to array of pointers to first chars of strings", then "array" and "string" are meant in the generic way, not in the D-specific way.

Reply via email to