Thread overview | |||||||
---|---|---|---|---|---|---|---|
|
August 16, 2003 odd error | ||||
---|---|---|---|---|
| ||||
Why doesn't this code work? I'm using dmd 0.69. It worked with 0.68.. void main() { char[] s = "Hello"; if(s[0] == "H") { printf(s); } } I get: hello.d(4): incompatible types for ((cast(int)(s[0])) == ("H")): 'int' and 'char[1]' |
August 16, 2003 Re: odd error | ||||
---|---|---|---|---|
| ||||
Posted in reply to Mårten Ask | "H" is a char[1] s[0] is a char try 'H' (char literal, not string literal) or "H"[0] ! there has been a change \n is not '\n' and 'foo' is not a string anymore. "Mårten Ask" <majbritt37@hotmail.com> wrote in message news:bhm5nk$7jf$1@digitaldaemon.com... > Why doesn't this code work? I'm using dmd 0.69. It worked with 0.68.. > > void main() > { > char[] s = "Hello"; > if(s[0] == "H") > { > printf(s); > } > } > > I get: > > hello.d(4): incompatible types for ((cast(int)(s[0])) == ("H")): 'int' and > 'char[1]' > > |
August 16, 2003 Re: odd error | ||||
---|---|---|---|---|
| ||||
Posted in reply to Mike Wynn | Thanks, it worked right away with single quotes. I feel stupid. :) "Mike Wynn" <mike.wynn@l8night.co.uk> skrev i meddelandet news:bhm8d5$bgh$1@digitaldaemon.com... > "H" is a char[1] s[0] is a char > try 'H' (char literal, not string literal) or "H"[0] ! > there has been a change \n is not '\n' and 'foo' is not a string anymore. > > "Mårten Ask" <majbritt37@hotmail.com> wrote in message news:bhm5nk$7jf$1@digitaldaemon.com... > > Why doesn't this code work? I'm using dmd 0.69. It worked with 0.68.. > > > > void main() > > { > > char[] s = "Hello"; > > if(s[0] == "H") > > { > > printf(s); > > } > > } > > > > I get: > > > > hello.d(4): incompatible types for ((cast(int)(s[0])) == ("H")): 'int' and > > 'char[1]' > > > > > > |
August 18, 2003 Re: odd error | ||||
---|---|---|---|---|
| ||||
Posted in reply to Mårten Ask | > Thanks, it worked right away with single quotes. I feel stupid. :)
Don't feel stupid. Feel her smarter older sister!
(Sorry, am a bit low on blood sugar at the moment ...)
|
August 18, 2003 Re: odd error | ||||
---|---|---|---|---|
| ||||
Posted in reply to Matthew Wilson | > (Sorry, am a bit low on blood sugar at the moment ...)
>
Well! You know how to fix that! LOL
|
Copyright © 1999-2021 by the D Language Foundation