Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

d
array
pointer
communitycreator

What is an array's ptr property in D programming?

Theodore Kelechukwu Onyejiaku

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.stdio
import std.stdio; 
 
// main method
void main(string[] args) { 
   // create an array
   string[3] languages;
   // add values 
   languages[0] = "D";
   languages[1] = "Swift";
   languages[2] = "C#";

   // print the pointer of first element
   writeln(languages.ptr); 
}
Get the Pointer of the array's first element in D

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.

RELATED TAGS

d
array
pointer
communitycreator

CONTRIBUTOR

Theodore Kelechukwu Onyejiaku
RELATED COURSES

View all Courses

Keep Exploring