D Programming Language: 2020 Edition by Publishing D

D Programming Language: 2020 Edition by Publishing D

Author:Publishing, D [Publishing, D]
Language: eng
Format: epub
Published: 2020-09-26T00:00:00+00:00


When the above code is compiled together and executed, it produces the following result −

Average is :214.4

Return Pointer from Functions

Consider the following function, which returns 10 numbers using a pointer, means the address of first array element.

import std. stdio ;

void main () {

int * p = getNumber();

for ( int i = 0 ; i < 10 ; i++ ) {

writeln( "*(p + " , i , ") : " ,*( p + i));

}

}

int * getNumber( ) {

static int r [ 10 ];

for ( int i = 0 ; i < 10 ; ++ i) {

r[ i] = i;

}

return & r[ 0 ];

}



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.