473,657 Members | 2,419 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

wwj
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.
Nov 13 '05 #1
24 3620
In article <87************ **************@ posting.google. com>,
ww*******@mail2 .swjtu.edu.cn (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.
Nov 13 '05 #2
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_pleas e_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

Nov 13 '05 #3
wwj
......~~
Christian Bau <ch***********@ cbau.freeserve. co.uk> wrote in message news:<ch******* *************** ***********@slb-newsm1.svr.pol. co.uk>...
In article <87************ **************@ posting.google. com>,
ww*******@mail2 .swjtu.edu.cn (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.

Nov 13 '05 #4
wwj
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 <bd***********@ removeme.free.f r> wrote in message news:<3f******* *************** *@news.free.fr> ...
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_pleas e_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

Nov 13 '05 #5
wwj <ww*******@mail 2.swjtu.edu.cn> 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 (pa*****@cc.hel sinki.fi) ------------- Finland --------\
\-- http://www.helsinki.fi/~palaste --------------------- rules! --------/
"You could take his life and..."
- Mirja Tolsa
Nov 13 '05 #6
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
Nov 13 '05 #7
Joona I Palaste wrote:
wwj <ww*******@mail 2.swjtu.edu.cn> 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 (cb********@yah oo.com) (cb********@wor ldnet.att.net)
Available for consulting/temporary embedded and systems.
<http://cbfalconer.home .att.net> USE worldnet address!
Nov 13 '05 #8
wwj
i have said its my wrong to post it here !!!!!!!
Joona I Palaste <pa*****@cc.hel sinki.fi> 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?

Nov 13 '05 #9
wwj
why?why apologize for my poor behavior ?what is my poor behavior?
Default User <fi********@boe ing.com.invalid > wrote in message news:<3F******* ********@boeing .com.invalid>.. .
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

Nov 13 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
16995
by: wwj | last post by:
Hi ,all I want to know the difference between char a and char *p=new char and the difference between the heap and the stack ,and if the char a is corresponding to the stack in MEMORY,and char *p=new char is corresponding to the heap of MEMORY. Give me some hint. THANK YOU.
7
1600
by: Paul | last post by:
Say I have: char foo; char** bar; In my understanding, these two have the same meaning in memory. Could someone elucidate upon these two types and their meanings? Thanks, Paul
9
13101
by: bill | last post by:
Forget the exact definition of difference between, #include <foo.h> and #include "bar.h" Normally foo.h is a standard header file, so it's path is not defined in compiler option, but I am curious how compiler find it.
10
15646
by: tinesan | last post by:
Hello fellow C programmers, I'm just learning to program with C, and I'm wondering what the difference between signed and unsigned char is. To me there seems to be no difference, and the standard doesn't even care what a normal char is (because signed and unsigned have equal behavior). For example if someone does this: unsigned char a = -2; /* or = 254 */
61
3122
by: academic | last post by:
When I declare a reference variable I initialize it to Nothing. Now I'm wondering if that best for String variables - is "" better? With Nothing I assume no memory is set aside nor GC'ed But with "" it is - correct? The system seems to handle a null the same as "".
7
3446
by: iamchiaweilin | last post by:
Hello all: What's the difference between p and q in the following statements? char p = "Hello"; char *q = "Hello"; I know q stores the address of 'H'. Question is: does p store the address of 'H' too?
13
17125
by: In a little while | last post by:
thanks
3
2142
by: artifact.one | last post by:
Hi. What's the practical difference between: #include <header.h> and: #include "header.h"
13
2493
by: manish sahu | last post by:
difference between calloc() and malloc()
0
8402
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8315
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8829
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8508
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8608
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5633
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4164
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2733
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1627
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.