Velocity Reviews > The difference between char a[6] and char *p=new char[6] ?

# The difference between char a[6] and char *p=new char[6] ?

wwj
Guest
Posts: n/a

 11-03-2003
Hi ,all

I want to know the difference between char a[6] and char *p=new
char[6] and the difference between the heap and the stack ,and if the
char a[6] is corresponding to the stack in MEMORY,and char *p=new
char[6] is corresponding to the heap of MEMORY.

Give me some hint.
THANK YOU.

Christian Bau
Guest
Posts: n/a

 11-03-2003
In article <(E-Mail Removed) >,
http://www.velocityreviews.com/forums/(E-Mail Removed) (wwj) wrote:

> Hi ,all
>
> I want to know the difference between char a[6] and char *p=new
> char[6] and the difference between the heap and the stack ,and if the
> char a[6] is corresponding to the stack in MEMORY,and char *p=new
> char[6] is corresponding to the heap of MEMORY.

Could you have a very very close look at the name of the newsgroup you
are posting to? Is the name of that newsgroup "comp.lang.c++"? If not,
then you are posting your C++ questions to the wrong newsgroup.

Bruno Desthuilliers
Guest
Posts: n/a

 11-03-2003
wwj wrote:
> Hi ,all
>
> I want to know the difference between char a[6] and char *p=new
> char[6]

The difference is that the second statement has no meaning in C.
C++ is the second group down the hall, on the the left...

> and the difference between the heap and the stack,

This has nothing to do with the C language.

> and if the
> char a[6] is corresponding to the stack in MEMORY,and char *p=new
> char[6] is corresponding to the heap of MEMORY.

Since the C language has no notion of stack or heap, and since the
second statement has no meaning in C, we can't answer such a question.

> Give me some hint.

first hint : C and C++ are two different languages. please post on the
appropriate newsgroup.

second hint :

C <ot>and C++</ot> have a notion of automatic memory and a notion of
dynamic memory.

Automatic memory is the default storage, and local variables are usually
automatic. This means that memory is automatically allocated for these
variable at the beginning of the block, and that this memory is
automatically freed at the end of the block.

Automatic memory *may* be, on *some* platforms, implemented with a stack.

Dynamic memory is memory that is allocated on demand, with a special
mechanism (in C, usually the 'malloc()' function, <ot>in C++ usually the
'new' operator</ot>), and that must be freed by code - usually in C with
the 'free()' function <ot>and in C++ with 'delete'</ot>). Not freeing
dynamically allocated memory (usually) causes a 'memory leak'.

Dynamic memory *may* be, on *some* platforms, implemented with a 'heap'.

Third hint : please learn the difference between C and C++, choose the
one you like, get yourself a *good* book on it, and post on the
appropriate group - after you've read the group's FAQ.

> THANK YOU.

Please dont scream, it's hurting my ears.

Bruno

wwj
Guest
Posts: n/a

 11-03-2003
......~~
Christian Bau <(E-Mail Removed)> wrote in message news:<(E-Mail Removed)>...
> In article <(E-Mail Removed) >,
> (E-Mail Removed) (wwj) wrote:
>
> > Hi ,all
> >
> > I want to know the difference between char a[6] and char *p=new
> > char[6] and the difference between the heap and the stack ,and if the
> > char a[6] is corresponding to the stack in MEMORY,and char *p=new
> > char[6] is corresponding to the heap of MEMORY.

>
> Could you have a very very close look at the name of the newsgroup you
> are posting to? Is the name of that newsgroup "comp.lang.c++"? If not,
> then you are posting your C++ questions to the wrong newsgroup.

wwj
Guest
Posts: n/a

 11-03-2003
Bruno ,Anyway firstly I thank you ,it's my wrong to post it here and
now yet I can not tell from c and c++ well. Then,I want to say that
our world is developing ,all developing,and the language c not be
invent from uk or by you or Christian Bau,ple you do not regulate(this
word not proper) it or sneer at others (new one) or rave at others .
Bruno Desthuilliers <(E-Mail Removed)> wrote in message news:<3fa61449\$0\$27023\$(E-Mail Removed)>...
> wwj wrote:
> > Hi ,all
> >
> > I want to know the difference between char a[6] and char *p=new
> > char[6]

>
> The difference is that the second statement has no meaning in C.
> C++ is the second group down the hall, on the the left...
>
> > and the difference between the heap and the stack,

>
> This has nothing to do with the C language.
>
> > and if the
> > char a[6] is corresponding to the stack in MEMORY,and char *p=new
> > char[6] is corresponding to the heap of MEMORY.

>
> Since the C language has no notion of stack or heap, and since the
> second statement has no meaning in C, we can't answer such a question.
>
> > Give me some hint.

>
> first hint : C and C++ are two different languages. please post on the
> appropriate newsgroup.
>
> second hint :
>
>
> C <ot>and C++</ot> have a notion of automatic memory and a notion of
> dynamic memory.
>
> Automatic memory is the default storage, and local variables are usually
> automatic. This means that memory is automatically allocated for these
> variable at the beginning of the block, and that this memory is
> automatically freed at the end of the block.
>
> Automatic memory *may* be, on *some* platforms, implemented with a stack.
>
> Dynamic memory is memory that is allocated on demand, with a special
> mechanism (in C, usually the 'malloc()' function, <ot>in C++ usually the
> 'new' operator</ot>), and that must be freed by code - usually in C with
> the 'free()' function <ot>and in C++ with 'delete'</ot>). Not freeing
> dynamically allocated memory (usually) causes a 'memory leak'.
>
> Dynamic memory *may* be, on *some* platforms, implemented with a 'heap'.
>
> Third hint : please learn the difference between C and C++, choose the
> one you like, get yourself a *good* book on it, and post on the
> appropriate group - after you've read the group's FAQ.
>
> > THANK YOU.

> Please dont scream, it's hurting my ears.
>
> Bruno

Joona I Palaste
Guest
Posts: n/a

 11-03-2003
wwj <(E-Mail Removed)> scribbled the following:
> Bruno ,Anyway firstly I thank you ,it's my wrong to post it here and
> now yet I can not tell from c and c++ well. Then,I want to say that
> our world is developing ,all developing,and the language c not be
> invent from uk or by you or Christian Bau,ple you do not regulate(this
> word not proper) it or sneer at others (new one) or rave at others .

In other words, because neither Bruno or Christian invented C, this
newsgroup can freely be abused by posting off-topic messages which don't
concern C at all?

--
/-- Joona Palaste ((E-Mail Removed)) ------------- Finland --------\
\-- http://www.helsinki.fi/~palaste --------------------- rules! --------/
"You could take his life and..."
- Mirja Tolsa

Default User
Guest
Posts: n/a

 11-03-2003
wwj wrote:
>
> Bruno ,Anyway firstly I thank you ,it's my wrong to post it here and
> now yet I can not tell from c and c++ well. Then,I want to say that
> our world is developing ,all developing,and the language c not be
> invent from uk or by you or Christian Bau,ple you do not regulate(this
> word not proper) it or sneer at others (new one) or rave at others .

Don't top-post. Your replies belong following properly trimmed quotes.

This newsgroup has topicality guidelines, which will be enforced by all
the regulars. Those two happened to be the first to correct you, others
would certainly have if they hadn't.

I suggest you apologize to the group and the two individuals for your
poor behavior.

Brian Rodenborn

CBFalconer
Guest
Posts: n/a

 11-03-2003
Joona I Palaste wrote:
> wwj <(E-Mail Removed)> scribbled the following:
>
> > Bruno ,Anyway firstly I thank you ,it's my wrong to post it here and
> > now yet I can not tell from c and c++ well. Then,I want to say that
> > our world is developing ,all developing,and the language c not be
> > invent from uk or by you or Christian Bau,ple you do not regulate(this
> > word not proper) it or sneer at others (new one) or rave at others .

>
> In other words, because neither Bruno or Christian invented C, this
> newsgroup can freely be abused by posting off-topic messages which don't
> concern C at all?

wwj obviously has a language barrier, and is doing his/her best.
So there is no need to pick at him. Simply drop it, and see what
develops. He already explained he doesn't know the difference
between C and C++, and obviously has not been told to lurk before
posting.

--
Chuck F ((E-Mail Removed)) ((E-Mail Removed))
Available for consulting/temporary embedded and systems.

wwj
Guest
Posts: n/a

 11-04-2003
i have said its my wrong to post it here !!!!!!!
Joona I Palaste <(E-Mail Removed)> wrote in message
> In other words, because neither Bruno or Christian invented C, this
> newsgroup can freely be abused by posting off-topic messages which don't
> concern C at all?

wwj
Guest
Posts: n/a

 11-04-2003
why?why apologize for my poor behavior ?what is my poor behavior?
Default User <(E-Mail Removed)> wrote in message news:<(E-Mail Removed)>...
> Don't top-post. Your replies belong following properly trimmed quotes.
>
>
> This newsgroup has topicality guidelines, which will be enforced by all
> the regulars. Those two happened to be the first to correct you, others
> would certainly have if they hadn't.
>
> I suggest you apologize to the group and the two individuals for your
> poor behavior.
>
>
>
>
> Brian Rodenborn