Velocity Reviews - Computer Hardware Reviews

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

Reply
Thread Tools

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.
 
Reply With Quote
 
 
 
 
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.
 
Reply With Quote
 
 
 
 
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 :

#include <regulars_please_correct_me_if_necessary.h>

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

 
Reply With Quote
 
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.

 
Reply With Quote
 
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 :
>
> #include <regulars_please_correct_me_if_necessary.h>
>
> 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

 
Reply With Quote
 
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
 
Reply With Quote
 
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
 
Reply With Quote
 
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.
<http://cbfalconer.home.att.net> USE worldnet address!


 
Reply With Quote
 
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?

 
Reply With Quote
 
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

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
(const char *cp) and (char *p) are consistent type, (const char **cpp) and (char **pp) are not consistent lovecreatesbeauty C Programming 1 05-09-2006 08:01 AM
Difference between bin and obj directories and difference between project references and dll references jakk ASP .Net 4 03-22-2005 09:23 PM
the difference between char a[6] and char *p=new char[6] . wwj C++ 7 11-05-2003 12:59 AM
difference(s) between char** argv and char* argv[] David C Programming 10 09-15-2003 06:58 AM
Exact difference between 'const char *' and 'char *', also diff between 'const' and 'static' Santa C Programming 1 07-17-2003 02:10 PM



Advertisments