On Mon, 17 Dec 2007 00:35:18 -0800 (PST), Pallav singh
<si**********@gmail.comwrote in comp.lang.c++:
Hi
if i declare globally its get store id BSS / Data
segment .................with size a.out we can verify
The '.' key on your keyboard seems to be broken. In English, there
are places where a single '.' character is used, after an abbreviation
or at the end of a sentence. And there are places where an ellipsis
is used, which is exactly three '.' characters, like this: ...
There is no place in the English language where two or four or
seventeen continuous '.' characters has any meaning at all.
As for your assertion, maybe your particular C++ compiler has things
called "BSS" or "Data" segments. The C++ language has no such things,
leaving the details up to the compiler.
where does array is allocated memory when its declared inside a
function ......... i only see a change a little bit in Text ( Code )
Segment Size only
Automatic objects allocated inside a function go wherever the compiler
implementer decided to put them. The C++ language does not specify.
If you want to know how your particular compiler does these things,
ask in a group that discusses your specific compiler.
Thanks
Pallav Singh
If your compiler accepts the code below, either it is completely
broken, or perhaps it is a C compiler. The code is ill-formed for
C++.
#include<stdio.h>
<stdio.his deprecated in C++ in favor of <cstdio>.
char p[40];
static double d;
int i = 10;
static long l = 20;
int main()
{
int arr[1000] = {0};
int array[1000] = {0};
int i =3 , j ,*ip;
ip=(int *)malloc(sizeof(i));
There is no declaration in scope for malloc(), because you have not
included <cstdlibor even <stdlib.h>. A conforming C++ compiler will
not accept a call to a function without a proper declaration in scope.
The cast will allow older C compilers, prior to the 1999 version of
the C standard, to accept the code without a diagnostic. For versions
of the C standard from 1999 later, calling a function without a
declaration is a constraint violation.
In all versions of C and C++, this code is just plain wrong, and
produces undefined behavior.
p[5] = i;
d = 2.0 * 20;
return 0;
}
--
Jack Klein
Home:
http://JK-Technology.Com
FAQs for
comp.lang.c
http://c-faq.com/
comp.lang.c++
http://www.parashift.com/c++-faq-lite/
alt.comp.lang.learn.c-c++
http://www.club.cc.cmu.edu/~ajo/docs/FAQ-acllc.html