473,242 Members | 1,481 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,242 software developers and data experts.

static structure

i am confused about static structure...

static struct
{
int a;

}st;

what is the difference between static structure and normal structure?
Jun 1 '07 #1
7 54728
Savage
1,764 Expert 1GB
i am confused about static structure...

static struct
{
int a;

}st;

what is the difference between static structure and normal structure?
If static keyword is applied to struct(or class),all of the members are static.

Savage
Jun 1 '07 #2
svlsr2000
181 Expert 100+
If static keyword is applied to struct(or class),all of the members are static.

Savage
hi savage,
is this c++ or java. I dont think there is something like static class in c++
please see this. I have not come across this in my compiler document.
:(
http://www.thescripts.com/forum/thread647427.html
Jun 1 '07 #3
i have to know about static struct in c-language..
Jun 1 '07 #4
when we declare static to a structure all the element will not become static...
because when varibales of structure are being re-intialized again...where as in static varibale will not reintialize .....

Then what is the use of declaring a structure as static?
Jun 1 '07 #5
Banfa
9,065 Expert Mod 8TB
If static keyword is applied to struct(or class),all of the members are static.
This isn't right.

It is not the structure that is declared static but the variable st. A variable declaration has the basic structure

[Storage Specifiers] [Type] [Variable Name];

This this case

Storage Specifiers
static

Type
struct
{
int a;

}

Variable Name
st

What the static keyword means is somewhat dependent on where this declaration appears in the rest of the code. Inside a function it indicates that the variable should not be put on the stack but in the data segment and is persistent while the function is not running. Outside a function it merely indicates that the variable is not accessable outside the file it is in.

So the static in your declaration means exactly the same as the static in this declaration

Expand|Select|Wrap|Line Numbers
  1. static int integer_variable;
  2.  
Jun 1 '07 #6
AdrianH
1,251 Expert 1GB
This isn't right.

It is not the structure that is declared static but the variable st. A variable declaration has the basic structure

[Storage Specifiers] [Type] [Variable Name];

This this case

Storage Specifiers
static

Type
struct
{
int a;

}

Variable Name
st

What the static keyword means is somewhat dependent on where this declaration appears in the rest of the code. Inside a function it indicates that the variable should not be put on the stack but in the data segment and is persistent while the function is not running. Outside a function it merely indicates that the variable is not accessable outside the file it is in.

So the static in your declaration means exactly the same as the static in this declaration

Expand|Select|Wrap|Line Numbers
  1. static int integer_variable;
  2.  
Thank you Ben, when I was reading all of the responses, I was about to scream. ;)

And just to clarify, the struct specified is what is called an anonymous struct. It is has no name.


Adrian
Jun 1 '07 #7
zidane
1
it's sure that we can write static struct on c program
that's a way to prohibit the user to access on the structure
from outside ,
it's generally used on stack defenition
Dec 20 '11 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Tino | last post by:
From Stroustrup( TC++PL, Appendix C.13 ) I thought that this was the way (and the only way perhaps) to have a common static member for all classes generated from a template. Though compiling this...
7
by: Raxit | last post by:
Can A C Program having static Variable in Structure is possible..... i.e. struct A { int a; static int b; };
0
by: Shrage H. Smilowitz | last post by:
I have posted this question in the vision forum and got no response, so maybe one of the vb developers here can aswere me. In VB.net classes can have Properties (Attributes in UML), Functions...
4
by: sandeep | last post by:
Hi why we cannot have static as a structure member? & also is there any way to achive data hiding in C at this level( i.e. access only selected structure member ) following code gives syntax...
6
by: Aston Martin | last post by:
Hi All, ********************** My Situation ********************** I am working on project that involves passing a structure to unmanaged code from .Net world (well using C#). Perhaps an example...
5
by: kselvaakumar | last post by:
I have declared a global structure like this: struct { float a; float b; }static one; This is in a separate header file file1.h; Now how can i initialise those variables one.a and one.b in...
5
by: Bob Altman | last post by:
Hi all, I have a private static structure in a C++ class (it's a CRITICAL_SECTION structure) that needs to be initialized by passing its address to a routine (InitializeCriticalSection). Since...
27
by: arkmancn | last post by:
Any comments? thanks. Jim
6
by: jeddiki | last post by:
I am struggling with how I should store this data. I get an xlm update every day which contains about 20,000 rows of data. There are some new rows, maybe 150 a week, and some of the existing rows...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...

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.