What is an array's ptr property in D programming?
Overview
An array’s ptr property in D returns the pointer of an array’s first element.
Syntax
array.ptr
Return value
The value returned is a pointer value of the array’s first element.
Example
// import std.stdioimport std.stdio;// main methodvoid main(string[] args) {// create an arraystring[3] languages;// add valueslanguages[0] = "D";languages[1] = "Swift";languages[2] = "C#";// print the pointer of first elementwriteln(languages.ptr);}
Explanation
- Line 7: We create an array.
- Lines 9-11: We allocate the array some values.
- line 14: We print the first statement’s pointer.