Re: char array question

From: Mabden (mabden_at_sbc_global.net)
Date: 08/07/04


Date: Sat, 07 Aug 2004 02:03:20 GMT


"ali" <tj@raha.com> wrote in message
news:t328h0tkrhhe8al9g1hp8td5ascnij7vmv@4ax.com...
> Hi,
>
> I'm having a problem understanding the reason for output on the
> following code:
>
> #include <iostream.h>
>
> int main()
> {
>
> char array[]={'w','e','l','c','o','m','e'};
>
> cout<<array<<endl;
>
> return 0;
> }
>
> When i run this, the output is something like this:
>
> welcomeŚ+ ?

In addition to what everyone else will tell you, I'd like to add that C
strings must be terminated by a null ('\0'). Just in case that message
doesn't get through.

-- 
Mabden\0


Relevant Pages

  • Re: char array question
    ... ali wrote: ... > I'm having a problem understanding the reason for output on the ... > int main ...
    (comp.lang.cpp)
  • Re: char array question
    ... > I'm having a problem understanding the reason for output on the ... > int main ...
    (comp.lang.cpp)
  • Re: char array question
    ... > I'm having a problem understanding the reason for output on the ... > int main ... This is character ...
    (comp.lang.cpp)
  • char array question
    ... I'm having a problem understanding the reason for output on the ... int main ...
    (comp.lang.cpp)
  • Re: SysInternals acquired by Microsoft
    ... anton bassov wrote: ... You seem to be "a voice of reason", and I fully agree with your ... Ali wrote: ... wininternals), and ofcourse how come non-technical person would have ...
    (microsoft.public.win32.programmer.kernel)

Loading