Hi,
I have heard a question in C data storage i want to know where
the auto,static and global variables are get stored and what are the
memory segments like stack heap and its allocation.
waiting for reply. 5 1616
kanalkannan wrote:
Hi,
I have heard a question in C data storage i want to know where
the auto,static and global variables are get stored and what are the
memory segments like stack heap and its allocation.
waiting for reply.
These details are specific to the compiler and it's target system.
On Jan 7, 3:35 pm, kanalkannan <m.selvakan...@ gmail.comwrote:
Hi,
I have heard a question in C data storage i want to know where
the auto,static and global variables are get stored and what are the
memory segments like stack heap and its allocation.
waiting for reply.
They're compiler specific and not very important, you can create your
own segment, with any name you like.
Wang Jiaji <ji********@gma il.comwrites:
On Jan 7, 3:35 pm, kanalkannan <m.selvakan...@ gmail.comwrote:
>Hi, I have heard a question in C data storage i want to know where the auto,static and global variables are get stored and what are the memory segments like stack heap and its allocation.
waiting for reply.
They're compiler specific
True.
and not very important,
Probably true, though they might be important in some contexts.
you can create your
own segment, with any name you like.
Oh? C has no concept of "segments". Any mechanism for creating your
own would be extremely system-specific.
--
Keith Thompson (The_Other_Keit h) <ks***@mib.or g>
[...]
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
On Mon, 7 Jan 2008 09:42:10 -0600, Keith Thompson wrote
(in article <87************ @kvetch.smov.or g>):
Wang Jiaji <ji********@gma il.comwrites:
>you can create your own segment, with any name you like.
Oh? C has no concept of "segments". Any mechanism for creating your
own would be extremely system-specific.
int segment; /* this is my segment, there are many like it
* but this one is mine.
*/
--
Randy Howard (2reply remove FOOBAR)
"The power of accurate observation is called cynicism by those
who have not got it." - George Bernard Shaw
On Jan 6, 11:35*pm, kanalkannan <m.selvakan...@ gmail.comwrote:
Hi,
* * * * I have heard a question in C data storage i want to know where
the auto,static and global variables are get stored and what are the
memory segments like stack heap and its allocation.
All auto variables are placed into automatic storage.
All variables allocated with malloc() or calloc() are placed in
allocated storage.
All variables that are static or global have static duration.
Stack and heap do not appear in the standard. Many compilers place
automatic storage on a stack. Many compilers place allocated storage
on a heap. From the C language's perspective, understanding of the
physical location is not necessary to use the memory. There is no
imporant reason that all three types of storage could not be in the
same type of physical structures and general locations.
If you really want to know where something resides, take the address
of it (unless it is already an address) and (after casting to void *)
print the address with a %p format specifier. That will tell you
where the variable is located. Of course, it could be a symbolic
address running in a virtual machine, but that's neither here nor
there. You would get the compiler's view of where the data lives
exactly in any case. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: bartek |
last post by:
Hello,
I've been pondering with this for quite some time now, and finally
decided to ask here for suggestions. I'm kind of confused, actually...
Maybe I'm thinking too much...
Brain dump follows...
I need a class to represent a variable, with an associated data type
and/or value. Though, I don't want it to be a variant type, and not a
|
by: Bryan Parkoff |
last post by:
.....I try to reduce un-necessary temporal variables so it can be
optimized for best performance. I try to assign only one register
storage so two variables can access to only one register storage
before they are stored into memory location (variable storage).
.....Please take a look at two functions below. Byte variable and
Carry variable are global variables outside of functions.
.....Do you notice that there are two duplicated lines...
|
by: ravi_shankar |
last post by:
I know java,but I am just beginner in C.I have some confusions
regarding extern storage specifier and default storage class specifier
for a variable when it has file scope that is ,when it is not
defined within
any block
--
Posted via http://dbforums.com
|
by: Datta Patil |
last post by:
Hi ,
#include<stdio.h>
func(static int k) /* point2 : why this is not giving error */
{
int i = 10 ;
// static int j = &i ; /* point 1: this will give compile time error */
return k;
}
/* in above case where is variable k and j mapped in memory layout ? */
|
by: junw2000 |
last post by:
When I define a static variable, where is the memory allocated for the
static variable?
Thanks.
Jack
| |
by: John |
last post by:
Does the length of my C variable names have any affect, performance-wise, on
my final executable program? I mean, once compiled, etc., is there any
difference between these two:
number = 3;
n = 3;
I know its setting aside storage for the variable itself; does it also use
up more storage if the variable name is longer? I realize it would probably
take quite a lot of long variable names to make any impact if so, but I was
just curious...
|
by: onkar |
last post by:
Given the following code & variable i .
int main(int argc,char **argv){
int i;
printf("%d\n",i);
return 0;
}
here i is allocated from bss or stack ?
|
by: subramanian100in |
last post by:
Suppose I declare a global variable
int g;
in two different files say a.c which has main() and b.c
When I compile them to build an executable under gcc in Redhat Linux
with the command
gcc -std=c99 -pedantic -Wall -Wextra a.c b.c
|
by: istillshine |
last post by:
When I control if I print messages, I usually use a global variable
"int silent". When I set "-silent" flag in my command line
parameters, I set silent = 1 in my main.c.
I have many functions that may print some messages.
foo(...)
{
if (!silent)
|
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,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
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,...
|
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...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
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();...
|
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...
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
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...
| |