Stack idea

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
bergen110
Posts: 9
Joined: Sun May 02, 2010 3:56 am

Stack idea

Post by bergen110 »

Hello,

I have the idea to make a sort of stack in C that writes to a memory location.
But is this idea efficient? or are there better ways to store fast a variable, if you need to use it short after you store it?
User avatar
gravaera
Member
Member
Posts: 737
Joined: Tue Jun 02, 2009 4:35 pm
Location: Supporting the cause: Use \tabs to indent code. NOT \x20 spaces.

Re: Stack idea

Post by gravaera »

Yo,

Code: Select all

int myFunction(void)
{
   int myLocalArg;

   // Do something;
};
The answer to your question is on line 3.

--Peace out,
gravaera
17:56 < sortie> Paging is called paging because you need to draw it on pages in your notebook to succeed at it.
bergen110
Posts: 9
Joined: Sun May 02, 2010 3:56 am

Re: Stack idea

Post by bergen110 »

I've made a fault in my starting post. i want to use it in another function.
I know that i can use global vars, but a simple call to a function that writes it to a memory location i simpler?
gerryg400
Member
Member
Posts: 1801
Joined: Thu Mar 25, 2010 11:26 pm
Location: Melbourne, Australia

Re: Stack idea

Post by gerryg400 »

Like alloca() ?
If a trainstation is where trains stop, what is a workstation ?
bergen110
Posts: 9
Joined: Sun May 02, 2010 3:56 am

Re: Stack idea

Post by bergen110 »

Yes, thats the solution, thanks!
i am going to implement that function
User avatar
JamesM
Member
Member
Posts: 2935
Joined: Tue Jul 10, 2007 5:27 am
Location: York, United Kingdom
Contact:

Re: Stack idea

Post by JamesM »

bergen110 wrote:Yes, thats the solution, thanks!
i am going to implement that function
It's a compiler intrinsic. It comes with GCC.
bergen110
Posts: 9
Joined: Sun May 02, 2010 3:56 am

Re: Stack idea

Post by bergen110 »

So i can use it without writing it?
Pretty cool!
Post Reply