473,831 Members | 2,341 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

stack

jt
hello everyone..

int fun()
{
/* anything */
}
int main(void)
{
fun();
}

in this program, when the control is transferred to function fun()..
the return address is pushed to the stack..
Is it possible to access this value..??
Aug 3 '08
62 2900


"CBFalconer " <cb********@yah oo.comwrote in message
news:48******** *******@yahoo.c om...
Harold Aptroot wrote:
>"MisterE" <Mi*****@nimga. comwrote in message
>>>Is it possible to access this value..??

No.

Of course it is. The OP did not request a standard compliant
way to do it after all

On this newsgroup, there are no non-standard compliant ways to do
anything. Anything of that nature is off=topic, and may be found
on specialized news-groups dealing with the authors system.
You mean to say that any solution that requires non-standard compliant code
temporarily ceases to exist when talking on this NG and everyone trying to
predend they Do exist will be flamed for OT-talk?
That seems to be happening anyhow

Aug 5 '08 #41
Harold Aptroot wrote:
"CBFalconer " <cb********@yah oo.comwrote in message
>Harold Aptroot wrote:
.... snip ...
>>
On this newsgroup, there are no non-standard compliant ways to
do anything. Anything of that nature is off=topic, and may be
found on specialized news-groups dealing with the authors system.

You mean to say that any solution that requires non-standard
compliant code temporarily ceases to exist when talking on this
NG and everyone trying to predend they Do exist will be flamed
for OT-talk? That seems to be happening anyhow
You've got it.

--
[mail]: Chuck F (cbfalconer at maineline dot net)
[page]: <http://cbfalconer.home .att.net>
Try the download section.
Aug 5 '08 #42
CBFalconer <cb********@yah oo.comwrites:
Keith Thompson wrote:
>CBFalconer <cb********@yah oo.comwrites:
... snip ...
>>
>>On this newsgroup, there are no non-standard compliant ways to do
anything. Anything of that nature is off=topic, and may be found
on specialized news-groups dealing with the authors system.
... snip ...
>>
People who post off-topic questions should not be punished by
being fed false information. And for that matter, the question
itself wasn't off-topic, though a detailed answer without a
redirection would have been.

I don't think I did 'punish'. I told him where to go, in general
terms. He didn't specify his system.
MisterE's response was just "No.", with no elaboration. You appeared
to be defending that response. Perhaps that wasn't your intent.

--
Keith Thompson (The_Other_Keit h) ks***@mib.org <http://www.ghoti.net/~kst>
Nokia
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
Aug 5 '08 #43
Harold Aptroot wrote:
>

"CBFalconer " <cb********@yah oo.comwrote in message
news:48******** *******@yahoo.c om...
>Harold Aptroot wrote:
>>"MisterE" <Mi*****@nimga. comwrote in message

Is it possible to access this value..??

No.

Of course it is. The OP did not request a standard compliant
way to do it after all

On this newsgroup, there are no non-standard compliant ways to do
anything. Anything of that nature is off=topic, and may be found
on specialized news-groups dealing with the authors system.

You mean to say that any solution that requires non-standard compliant
code temporarily ceases to exist when talking on this NG and everyone
trying to predend they Do exist will be flamed for OT-talk?
That seems to be happening anyhow
For my part, I draw the line a little more leniently than
CBF does. Nonetheless, I maintain that the line is a useful one:
There is an important distinction between things that can be done
with unaided C and things that require additional machinery or
additional assumptions.

The reason the distinction is important is that engineering
is an art of trade-offs, and the trade-offs should be made with
proper consideration and not out of ignorance. If you know that
doing a task in some particular way involves things C doesn't
provide or guarantee, then you can make a conscious assessment
about whether the increased capability justifies the diminished
portability. But if you *don't* know where the line is, you'll
wander across it all unaware, perhaps to be unpleasantly surprised
when your code doesn't work on the next machine. You need to be
aware of the boundary, so that you cross it only by decision and
not by accident.

Another reason to study the distinction is that the category
of things unaided C can do is larger than some people imagine.
For example, people are always asking how to discover a machine's
endianness so they can write code that swings both ways. Usually
they're shown a couple of tricks for testing and byte-swapping and
so on -- but often they're also shown "endian-blind" code that
just plain works, no matter how the underlying machine arranges
its integers. That is, they're shown an unaided-C way to solve a
problem that they originally thought needed machine-specific hacks.
That sort of improvement is a worthwhile gain, and should motivate
any serious practitioner to become more familiar with his tools.

Finally, when somebody wants to do something that unaided C
cannot do or cannot do well, the helpful response is to let them
know it's beyond the capabilities of unaided C and to refer them,
if possible, to sources where they can get more information about
the beyond-C capabilities they need. The alternative of dragging
all the beyond-C things into this group is not viable, simply
because the experts in those beyond-C things don't hang out here.
Among the people who frequent this group there are probably folks
who know quite a bit about networking, cryptography, numerical
analysis, random number generation, parsing of artificial and
natural languages, hardware-assisted 3D rendering, and on and on
and on. That's fine, and I for one am glad of their presence.
But the experts in any one such field are thin on the ground here,
not surrounded by their fellow experts who might clarify or correct
their responses. If somebody's working on a C program to reckon
dates according to ancient Babylonian calendars, this is a fine
forum for dealing with the C problems but not a good one for the
calendrical questions. There's probably someone here who knows
about Babylonian calendars and he might answer the question, but
there's nobody here to say "No, that's how the Sumerians did it;
the Babylonian system was quite different."

This group attracts (as it is intended to) a congregation of
people interested in and to varying degrees expert in C, and is
a splendid forum for C questions. Questions about shells, shared
memory, threads, eigenvalue computation, texture mapping, and the
approved protocols for financial computation belong elsewhere.
Because despite our high opinions of ourselves ("Hey, I can write
C -- I must be Really Smart!"), we don't quite Know It All.

--
Er*********@sun .com
Aug 5 '08 #44
santosh <sa*********@gm ail.comwrites:
Nick Keighley wrote:
>On 4 Aug, 22:30, CBFalconer <cbfalco...@yah oo.comwrote:
>>jt wrote:
>int fun() {
/* anything */
}
int main(void) {
fun();
}

in this program, when the control is transferred to function
fun().. the return address is pushed to the stack..
Is it possible to access this value..??

In a machine that can execute the standard C language, there is no
need for a stack. This makes it hard to access a return address
(of unknown form) stored in a non-existant stack.

but the information must be stored *somewhere* otherwise
the implementation wouldn't be able to return from the function.

And it must also *behave* like a LIFO data structure. So at least a
software based stack is necessary.
The word "stack" is commonly used in two different ways.

It can refer to a LIFO data structure, regardless of how it's
represented. A C implementation needs one of these to handle
recursive calls, and most likely all calls. (If a program can be
proven to have no recursive calls, an implementation might avoid the
use of a stack; this would make sense only if using a stack led to
relatively inefficent code.)

It can also refer to a specific implementation of a LIFO data
structure, as a contiguous chunk of memory that grows in a particular
direction, typically managed via a hardware stack pointer register.
The phrase "the stack" usually refers to this kind of stack, and I'm
sure it's what the OP was referring to when he said that "the return
address is pushed to the stack". C doesn't require this kind of
stack, and some real-world implementations don't use it.

--
Keith Thompson (The_Other_Keit h) ks***@mib.org <http://www.ghoti.net/~kst>
Nokia
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
Aug 5 '08 #45
Eric Sosman wrote:

<snip>

An excellent post. Should probably be kept around as a canned response
for the all too frequent topicality debates.

Aug 5 '08 #46
santosh said:
Eric Sosman wrote:

<snip>

An excellent post.
I agree.
Should probably be kept around as a canned response
for the all too frequent topicality debates.
It's considerably less than a year ago that we discussed topicality at some
length. Everyone had a chance to have their say, and many people availed
themselves of that opportunity. I see no reason why it needs to be dragged
up again for the time being. Once a year ought to be enough for anybody.

--
Richard Heathfield <http://www.cpax.org.uk >
Email: -http://www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999
Aug 5 '08 #47
Richard Heathfield <rj*@see.sig.in validwrites:
santosh said:
>Eric Sosman wrote:

<snip>

An excellent post.

I agree.
>Should probably be kept around as a canned response
for the all too frequent topicality debates.

It's considerably less than a year ago that we discussed topicality at some
length. Everyone had a chance to have their say, and many people availed
themselves of that opportunity. I see no reason why it needs to be dragged
up again for the time being. Once a year ought to be enough for anybody.
Are you related to Robert Mugabe by any chance?
Aug 5 '08 #48
In article <g7**********@r egistered.motza rella.org>,
Richard <rg****@gmail.c omwrote:
>Richard Heathfield <rj*@see.sig.in validwrites:
>It's considerably less than a year ago that we discussed topicality at some
length. Everyone had a chance to have their say, and many people availed
themselves of that opportunity. I see no reason why it needs to be dragged
up again for the time being. Once a year ought to be enough for anybody.
>Are you related to Robert Mugabe by any chance?
In my opinion, that was a completely unnecessary and extreme insult.

Richard Heathfield expressed an opinion, something that he is
entitled to do in democratic societies. The opinion was not
inherently inflamatory or inherently unreasonable: it was well
within the bounds of what might be believed by a "reasonable person
in full possession of the facts". I have seen no evidence to
suggest that Richard Heathfield is somehow forcing his opinion
upon others or defrauding others or changing rules post facto.

If you disagree with Richard Heathfield about the frequency of
reasonable debate upon topicality, then you could simply state
the frequency which you feel is appropriate and give reasons thereto.
But Richard Heathfield is correct, that the matter did get discussed
at length not long ago, and the majority opinion expressed was in
favour of strict topicality, so be aware that if your answer
about reasonable frequency of topicality debates is "anytime", then
there is a distinct risk that you would be viewed as being unconcerned
with what the majority expressed and instead only interested in
having *your* viewpoint adopted.
--
"The quirks and arbitrariness we observe force us to the
conclusion that ours is not the only universe." -- Walter Kistler
Aug 5 '08 #49
ro******@ibd.nr c-cnrc.gc.ca (Walter Roberson) writes:
In article <g7**********@r egistered.motza rella.org>,
Richard <rg****@gmail.c omwrote:
>>Richard Heathfield <rj*@see.sig.in validwrites:
>>It's considerably less than a year ago that we discussed topicality at some
length. Everyone had a chance to have their say, and many people availed
themselves of that opportunity. I see no reason why it needs to be dragged
up again for the time being. Once a year ought to be enough for anybody.
>>Are you related to Robert Mugabe by any chance?

In my opinion, that was a completely unnecessary and extreme insult.
Get off your high horse. It was a quip. Does your sense of humour not
meet the C Standard and you leave it at the door?
>
Richard Heathfield expressed an opinion, something that he is
entitled to do in democratic societies. The opinion was not
inherently inflamatory or inherently unreasonable: it was well
within the bounds of what might be believed by a "reasonable person
in full possession of the facts". I have seen no evidence to
suggest that Richard Heathfield is somehow forcing his opinion
upon others or defrauding others or changing rules post facto.
Heathfield trots out the vote thing time after time. The only people
interested enough were the usual c.l.c clique. It proved nothing.
Aug 5 '08 #50

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

Similar topics

15
7750
by: Andrew | last post by:
Last night I was reading about implementing my own stack. The example given pushes items on and off the stack at the start and end of each procedure (ie. in a std module). What's not so clear is how this would work with class objects. In this case do you have to push the object on the stack at the start of every public procedure etc. in the class and pop it off at the end? I can't see how else you can know which object is active - or...
14
30107
by: Kevin Grigorenko | last post by:
Hello, I couldn't find an obvious answer to this in the FAQ. My basic question, is: Is there any difference in allocating on the heap versus the stack? If heap or stack implementation is not part of the standard, then just disregard this question. Here's some questions I'm confused about, and if you can add anything else, please do so! Is the stack limited for each program?
4
2626
by: Chris Mabee | last post by:
Hello all, and Merry Christmas, I'm having a problem understanding an example of an array based implementation of a stack in a textbook of mine. The code in question is written below. The syntax is directly as in the book, except for where I added the comments at the lines I wanted to refer to or to skip sections of code. template <class Element_Type> class Stack {
4
3637
by: anonymous | last post by:
Thanks your reply. The article I read is from www.hakin9.org/en/attachments/stackoverflow_en.pdf. And you're right. I don't know it very clearly. And that's why I want to understand it; for it's useful to help me to solve some basic problem which I may not perceive before. I appreciate your help, sincerely.
8
2101
by: LedZep | last post by:
What up everyone, I have to write a program that uses a stack to determine whether a string is a palindrome (a string that is spelled identically backward and forward). The program has to ignore spaces, case sensitivity and punctuation. I need three text boxes. The first will be for input of the string. The second will display the string when the "check" button is clicked and the result of the analysis (string is a palindrome or is...
4
2152
by: alisaee | last post by:
plz check what i have made wrong what is requierd her is to creat class queue and class stack and run the push,pop operation . #include<iostream.h> #include<conio.h> #include<stdio.h> class stack { public:
16
4454
by: sarathy | last post by:
Hi all, I need a few clarifications regarding memory allocaion in C++. I apologize for the lengthy explanation. 1. In C++, Objects are allocated in heap. What does heap refer to? Is it an area in RAM/Memory or does it refer to a data structure being used for storing objects. 2. In C++, functions and its local variables go in stack. If local variables that are primitives go in stack, it is OK. But what
24
6593
by: John | last post by:
I know this is a very fundamental question. I am still quite confused if the program call stack stack should always grows upwards from the bottom, or the opposite, or doesn't matter?? That means the stack pointer should go upwards when there are "push" operations, and stack pointer should go downards when there are "pop" operations?? If this is the case, the address should go upwards (increasing) or downards (decreasing) then? i.e....
1
4224
by: alfie27 | last post by:
I currently have a working program that is a stack that stores integers. Now i have to convert it to store strings instead of integers. I have been working on this for hours and just keep getting errors of all kinds. I have decided to start from scratch. Any suggestions someone can give me would be greatly appreciated!! Here is the current code: #include <iostream> using std::cout; using std::cin; #include <cstring> using std::strcpy;
11
1788
by: tom | last post by:
Hi! Im new to Python and doing exercise found from internet. It is supposed to evaluate expression given with postfix operator using Stack() class. class Stack: def __init__(self): self.items = def push(self, item): self.items.append(item)
0
9793
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...
1
10534
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
10207
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
9317
agi2029
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...
1
7748
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5619
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
4416
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
3963
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3076
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.