Re: char array question
From: John Harrison (john_andronicus_at_hotmail.com)
Date: 08/07/04
- Next message: John Harrison: "Re: Quick sort and memory problems"
- Previous message: David Rubin: "Re: Latest"
- In reply to: ali: "char array question"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Sat, 07 Aug 2004 06:18:27 +0100
On Fri, 06 Aug 2004 18:42:55 -0400, ali <tj@raha.com> wrote:
> 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¦+ ?
>
> Will appreciate some help on understanding the concept.
>
> Thanks,
>
> ali
Change your array to this
char array[]={'w','e','l','c','o','m','e','\0'};
or this
char array[]="welcome";
Those are two different ways to add the nul terminateor that everyoe else
has told you about.
john
- Next message: John Harrison: "Re: Quick sort and memory problems"
- Previous message: David Rubin: "Re: Latest"
- In reply to: ali: "char array question"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|