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: K&R2 1.6 Arrays, exercise 1-13 (vertical histogram)
    ... | int main ... I thought you always initialised variables on declaration, ... This, of course, could have been done by initialising on declaration ... (If the latter reason is true, learning it would have done no good here, because Reason 1 would still have applied.) ...
    (comp.lang.c)