Thread overview
odd error
Aug 16, 2003
Mårten Ask
Aug 16, 2003
Mike Wynn
Aug 16, 2003
Mårten Ask
Aug 18, 2003
Matthew Wilson
Aug 18, 2003
John Reimer
August 16, 2003
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
"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
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
> 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
> (Sorry, am a bit low on blood sugar at the moment ...)
> 

Well! You know how to fix that! LOL