digitalmars.D - char => char[]
- bobef (4/4) Feb 16 2006 cannot cast char to char[]
- Oskar Linde (3/8) Feb 16 2006 Your char may only live in a register in the cpu. In order to cast it to...
- Hasan Aljudy (4/9) Feb 16 2006 I think it can be done with
- =?UTF-8?B?SnVsaW8gQ8Opc2FyIENhcnJhc2NhbCBVcnF1aWpv?= (12/17) Feb 16 2006 Not quite. While a char is an utf8 code point. char[1] its actually a
cannot cast char to char[] cannot cast char to char[1] this is what DMD says, but I don't see what's the big deal. It is obvious that char is char[1]. Maybe there is technical reason...
Feb 16 2006
bobef wrote:cannot cast char to char[] cannot cast char to char[1] this is what DMD says, but I don't see what's the big deal. It is obvious that char is char[1]. Maybe there is technical reason...Your char may only live in a register in the cpu. In order to cast it to a single element array, you need to allocate a memory location to store it.
Feb 16 2006
bobef wrote:cannot cast char to char[] cannot cast char to char[1] this is what DMD says, but I don't see what's the big deal. It is obvious that char is char[1]. Maybe there is technical reason...I think it can be done with assuming yourChar is a variable of type char
Feb 16 2006
bobef wrote:cannot cast char to char[] cannot cast char to char[1] this is what DMD says, but I don't see what's the big deal. It is obvious that char is char[1]. Maybe there is technical reason...Not quite. While a char is an utf8 code point. char[1] its actually a structure like this: char c = 'a'; struct CharArr1 { char* ptr = &c; size_t length = 1; } You can convert a char to a char[] with this code: char[] charArr1 = (&c)[0..1]; Julio César Carrascal Urquijo
Feb 16 2006