Re: Help on array pointers

2023-09-22 Thread Joe--- via Digitalmars-d-learn
On Monday, 18 September 2023 at 02:49:37 UTC, vino wrote: On Sunday, 17 September 2023 at 18:28:36 UTC, Joe wrote: On Friday, 15 September 2023 at 16:55:34 UTC, Vino wrote: [...] [...] char[] invalid = (cast(char*)malloc(char.sizeof * len))[0..len]; This is not the way to go about it.

Re: Help on array pointers

2023-09-17 Thread vino via Digitalmars-d-learn
On Sunday, 17 September 2023 at 18:28:36 UTC, Joe wrote: On Friday, 15 September 2023 at 16:55:34 UTC, Vino wrote: [...] [...] char[] invalid = (cast(char*)malloc(char.sizeof * len))[0..len]; This is not the way to go about it. You are mixing "pointer arrays" with "arrays". [...]

Re: Help on array pointers

2023-09-17 Thread Joe--- via Digitalmars-d-learn
On Friday, 15 September 2023 at 16:55:34 UTC, Vino wrote: On Friday, 15 September 2023 at 15:27:00 UTC, Vino wrote: On Friday, 15 September 2023 at 02:25:09 UTC, Joe wrote: On Thursday, 14 September 2023 at 14:21:09 UTC, Vino wrote: [...] A pointer is a type that points to something. It's

Re: Help on array pointers

2023-09-15 Thread Vino via Digitalmars-d-learn
On Friday, 15 September 2023 at 15:27:00 UTC, Vino wrote: On Friday, 15 September 2023 at 02:25:09 UTC, Joe wrote: On Thursday, 14 September 2023 at 14:21:09 UTC, Vino wrote: [...] A pointer is a type that points to something. It's literally that simple. Every piece of data and code exist

Re: Help on array pointers

2023-09-15 Thread Vino via Digitalmars-d-learn
On Friday, 15 September 2023 at 02:25:09 UTC, Joe wrote: On Thursday, 14 September 2023 at 14:21:09 UTC, Vino wrote: [...] A pointer is a type that points to something. It's literally that simple. Every piece of data and code exist somewhere in memory. Every piece of memory has an address.

Re: Help on array pointers

2023-09-14 Thread Joe--- via Digitalmars-d-learn
On Thursday, 14 September 2023 at 14:21:09 UTC, Vino wrote: Hi All, Request your help to guide me in understanding about pointers, the below code works,I have few question which i need your help for better understanding. Questions:1 ``` char[] invalid = (cast(char*)malloc(char.sizeof *

Re: Help on array pointers

2023-09-14 Thread vino via Digitalmars-d-learn
On Thursday, 14 September 2023 at 17:23:53 UTC, Vino wrote: On Thursday, 14 September 2023 at 15:33:45 UTC, Paul Backus wrote: On Thursday, 14 September 2023 at 14:21:09 UTC, Vino wrote: Questions:1 ``` char[] invalid = (cast(char*)malloc(char.sizeof * length))[0..length]; ``` The above

Re: Help on array pointers

2023-09-14 Thread Vino via Digitalmars-d-learn
On Thursday, 14 September 2023 at 15:33:45 UTC, Paul Backus wrote: On Thursday, 14 September 2023 at 14:21:09 UTC, Vino wrote: Questions:1 ``` char[] invalid = (cast(char*)malloc(char.sizeof * length))[0..length]; ``` The above statement allocate memory for char type and the size of the

Re: Help on array pointers

2023-09-14 Thread Paul Backus via Digitalmars-d-learn
On Thursday, 14 September 2023 at 14:21:09 UTC, Vino wrote: Questions:1 ``` char[] invalid = (cast(char*)malloc(char.sizeof * length))[0..length]; ``` The above statement allocate memory for char type and the size of the allocated memory is char.sizeof * length so what is the use of this