473,394 Members | 1,734 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

some problem of a.out

I am a beginner in c programming. Now I have a question:
[code]
main() {
int i = 3;
int j;
}
Compile it to a.out.
Where the 'i','j' be in the a.out, the bss section, date section, or in
the stack?
Think you!

Jan 16 '06 #1
14 1511
Kies Lee said:
I am a beginner in c programming. Now I have a question:
[code]
main() {
int i = 3;
int j;
}
Compile it to a.out.
Where the 'i','j' be in the a.out, the bss section, date section, or in
the stack?
There's no requirement for the compiler to create the objects anywhere at
all, because not doing so will not change the output of the program.

In any case, the answer to your question depends entirely on the
implementation. C compilers are not required to employ a bss section, a
date section, a data section, or a stack.
Think you!


You're wilcome.

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at above domain (but drop the www, obviously)
Jan 16 '06 #2
> There's no requirement for the compiler to create the objects anywhere at
all, because not doing so will not change the output of the program.


but most likely his code will be optimized to an empty main() returning
0
So i, or j exist nowhere. Besides, a.out has its own file format which
determines where things will be "unloaded" in memory during execution.
If you compiled to a .EXE file on dos, the places where your
constants/variables reside will be determined by your OS and your file
format.

Generally if you declare and define your variables like you did, they
reside on the stack (or auto store), which has different meaning
depending on your compiler and OS etc.

Therefore your question lies on the border of assembly and something
"else" (where "else" is definitely not standard C!!!) so an assembly
newsgroup will be better suited to give you pointers on how this works.

Jan 16 '06 #3
Richard Heathfield wrote:
Kies Lee said:

Think you!


You're wilcome.


No, that was him telling you to put your brain in gear, "Think, you!"
He left out a comma.

Brian

--
If televison's a babysitter, the Internet is a drunk librarian who
won't shut up.
-- Dorothy Gambrell (http://catandgirl.com)
Jan 16 '06 #4
see every thing i.e is auto variables stored in stack when a fuction
called , if you made it as static int i=3;
this will be stored in initialized data segment.
if you say static int j;
i,e uninitialized data segment and at runtime this will be assigned
to zero; samething with uninitiolized variables...
this will be stored in bss;
and initialized global variable get stored in datasegments

ok
take acre

Jan 16 '06 #5
raju said:
see every thing i.e is auto variables stored in stack
Chapter and verse, please. Where does the Standard guarantee that auto
variables are stored in a stack?
when a fuction
called , if you made it as static int i=3;
this will be stored in initialized data segment.
Chapter and verse, please.
if you say static int j;
i,e uninitialized data segment
Chapter and verse, please.
and at runtime this will be assigned
to zero; samething with uninitiolized variables...
this will be stored in bss;
Chapter and verse, please.
and initialized global variable get stored in datasegments


Chapter and verse, please.

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at above domain (but drop the www, obviously)
Jan 16 '06 #6
raju wrote:

Please provide context when replying. People might not have seen the
article you are replying to. For details on how to do this using Google
and other useful advice please see http://cfaj.freeshell.org/google/
see every thing i.e is auto variables stored in stack when a fuction
called ,
Wrong for a number of reasons. The C standard does not mandate the
existence of a stack and even on real implementation with a stack auto
variables are often stored only in registers if the compiler can get
away with it because that is more efficient.
if you made it as static int i=3;
this will be stored in initialized data segment.
Again, there may not be an initialised data segment. I've worked on real
systems without such a thing although they did (as the standard
mandates) initialise variables with static storage duration.
if you say static int j;
i,e uninitialized data segment and at runtime this will be assigned
to zero; samething with uninitiolized variables...
this will be stored in bss;
Again, not all systems have a bss section. However, you are correct that
the variables will be initialised to 0.
and initialized global variable get stored in datasegments


Again, there is no guarantee there is such a thing as a data segment.

Please don't assume that all the world is using the same system as you
since there are vast numbers of people using completely different
systems with different capabilities and terminology. Here we deal with
standard C not the specifics of your (or anyone else's) specific system.
--
Flash Gordon
Living in interesting times.
Although my email address says spam, it is real and I read it.
Jan 16 '06 #7
In article <dq**********@nwrdmz01.dmz.ncs.ea.ibs-infra.bt.com>,
Richard Heathfield <in*****@invalid.invalid> wrote:
raju said:
see every thing i.e is auto variables stored in stack


Chapter and verse, please. Where does the Standard guarantee that auto
variables are stored in a stack?


(etc)

You're wasting your breath, and I will tell you why. The morons who go on
about stacks and stuff here have certainly never heard of the Standard.
And I doubt they'd catch the meaning of your biblical references.

Jan 16 '06 #8
In article <dq**********@yin.interaccess.com> ga*****@interaccess.com writes:
In article <dq**********@nwrdmz01.dmz.ncs.ea.ibs-infra.bt.com>,
Richard Heathfield <in*****@invalid.invalid> wrote:
raju said:
see every thing i.e is auto variables stored in stack


Chapter and verse, please. Where does the Standard guarantee that auto
variables are stored in a stack?


You're wasting your breath, and I will tell you why. The morons who go on
about stacks and stuff here have certainly never heard of the Standard.
And I doubt they'd catch the meaning of your biblical references.


It is (if I remember right) not e biblical reference, but a reference
to this newsgroup: Dan Pop.
--
dik t. winter, cwi, kruislaan 413, 1098 sj amsterdam, nederland, +31205924131
home: bovenover 215, 1025 jn amsterdam, nederland; http://www.cwi.nl/~dik/
Jan 17 '06 #9
"Dik T. Winter" <Di********@cwi.nl> writes:
In article <dq**********@yin.interaccess.com> ga*****@interaccess.com writes:
> In article <dq**********@nwrdmz01.dmz.ncs.ea.ibs-infra.bt.com>,
> Richard Heathfield <in*****@invalid.invalid> wrote:
> >raju said:
> >> see every thing i.e is auto variables stored in stack
> >
> >Chapter and verse, please. Where does the Standard guarantee that auto
> >variables are stored in a stack?

>
> You're wasting your breath, and I will tell you why. The morons who go on
> about stacks and stuff here have certainly never heard of the Standard.
> And I doubt they'd catch the meaning of your biblical references.


It is (if I remember right) not e biblical reference, but a reference
to this newsgroup: Dan Pop.


I'm reasonably sure the phrase "chapter and verse" originally referred
(and still does) to biblical references. The Bible is divided into
"books", each books is divided into chapters, each chapter is divided
into verses. "John 3:16", for example, refers to the book of John,
chapter 3, verse 16.

The extension of the phrase to section/paragraph references in the C
standard is commonplace and fairly obvious. According to the Google
archives, the earliest use of the phrase in comp.lang.c was by Henry
Spencer on December 4, 1986 (referring to K&R1, which was the closest
thing we had to a standard at the time).

(Kenny is wrong as usual.)

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Jan 17 '06 #10
Dik T. Winter wrote:
.... snip ...
It is (if I remember right) not e biblical reference, but a
reference to this newsgroup: Dan Pop.


Speaking of whom, has anyone heard anything about him in the past
year or so? We miss his knowledge and diplomatic tone. (1/2 of
that is sarcastic).

--
"If you want to post a followup via groups.google.com, don't use
the broken "Reply" link at the bottom of the article. Click on
"show options" at the top of the article, then click on the
"Reply" at the bottom of the article headers." - Keith Thompson
More details at: <http://cfaj.freeshell.org/google/>
Jan 17 '06 #11
In article <ln************@nuthaus.mib.org>,
Keith Thompson <ks***@mib.org> wrote:
....
I'm reasonably sure the phrase "chapter and verse" originally referred
(and still does) to biblical references. The Bible is divided into
"books", each books is divided into chapters, each chapter is divided
into verses. "John 3:16", for example, refers to the book of John,
chapter 3, verse 16.
Yes, very true.
The extension of the phrase to section/paragraph references in the C
standard is commonplace and fairly obvious. According to the Google
archives, the earliest use of the phrase in comp.lang.c was by Henry
Spencer on December 4, 1986 (referring to K&R1, which was the closest
thing we had to a standard at the time).
Yes, very true.
(Kenny is wrong as usual.)


ITYM:

"Dik T. Winter" is wrong thie time. But we all have our off-days.

HTH, HAND.

Jan 17 '06 #12
Dik T. Winter said:
["Chapter and verse"] is (if I remember right) not e biblical reference,


Clearly its origins are Biblical (or rather, suprabiblical, since chapter
and verse divisions were not added to the Bible until roughly 1200AD +/- a
century or so), but equally clearly it is a widely understood expression. I
am quite certain (although I cannot prove) that I was familiar with the
expression in its wider sense long before I got onto the Net.

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at above domain (but drop the www, obviously)
Jan 17 '06 #13
On Tue, 17 Jan 2006 00:39:15 GMT, in comp.lang.c , Keith Thompson
<ks***@mib.org> wrote:
I'm reasonably sure the phrase "chapter and verse" originally referred
(and still does) to biblical references.
Sure did. But, trolls commnets notwithstanding, as I'm sure youre
aware C&V is common english usage for a precise reference to an
accepted text. Its use is far from restricted to CLC - see meaning 1
below for example.

http://www.thefreedictionary.com/chapter+and+verse
(Kenny is wrong as usual.)


Return to type then...
Mark McIntyre
--

----== Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups
----= East and West-Coast Server Farms - Total Privacy via Encryption =----
Jan 17 '06 #14
Kies Lee wrote:

I am a beginner in c programming. Now I have a question:
[code]
main() {
int i = 3;
int j;
}
Compile it to a.out.
Where the 'i','j' be in the a.out, the bss section,
date section, or in the stack?


The objects i and j themselves, won't be in a.out.
The instructions for creating the objects i and j,
will be in a.out.

--
pete
Jan 17 '06 #15

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

Similar topics

4
by: PHPkemon | last post by:
Hi there, A few weeks ago I made a post and got an answer which seemed very logical. Here's part of the post: PHPkemon wrote: > I think I've figured out how to do the main things like...
22
by: Martin MOKREJ© | last post by:
Hi, I'm looking for some easy way to do something like include in c or PHP. Imagine I would like to have: cat somefile.py a = 222 b = 111 c = 9
9
by: TPJ | last post by:
First I have to admit that my English isn't good enough. I'm still studying and sometimes I just can't express what I want to express. A few weeks ago I've written 'Python Builder' - a bash...
1
by: Az Tech | last post by:
Hi people, (Sorry for the somewhat long post). I request some of the people on this group who have good experience using object-orientation in the field, to please give some good ideas for...
193
by: Michael B. | last post by:
I was just thinking about this, specifically wondering if there's any features that the C specification currently lacks, and which may be included in some future standardization. Of course, I...
1
by: srikanth | last post by:
hi, I have one file it filled with some values in rows/colums. some times, some variables (in a particular row& column) may not be filled. depending on the kind its filled i will go for...
48
by: yezi | last post by:
Hi, all: I want to record some memory pointer returned from malloc, is possible the code like below? int memo_index; int i,j; char *tmp; for (i=0;i<10;i++){
24
by: Kevin | last post by:
Hey guys. I'm looking to get together some VB programmers on Yahoo messenger. I sit at a computer and program all day. I have about 3 or 4 people already, but it would be really cool to have a...
21
by: Jim | last post by:
I am trying to write an HTTP/HTTPS proxy server in VB.Net 2005. But, I don't really even know how the internal workings of a proxy should act. Does anyone have anything on the protocols used in...
6
by: TPJ | last post by:
Help me please, because I really don't get it. I think it's some stupid mistake I make, but I just can't find it. I have been thinking about it for three days so far and I still haven't found any...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
0
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,...
0
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...

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.