473,508 Members | 2,346 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

static structure

3 New Member
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 54766
Savage
1,764 Recognized Expert Top Contributor
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 Recognized Expert New Member
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
padmahasini
3 New Member
i have to know about static struct in c-language..
Jun 1 '07 #4
padmahasini
3 New Member
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 Recognized Expert Moderator Expert
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 Recognized Expert Top Contributor
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 New Member
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
4532
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
11987
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
939
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
2544
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
5883
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
8636
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
11103
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
5472
by: arkmancn | last post by:
Any comments? thanks. Jim
6
1924
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...
0
7225
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,...
1
7042
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...
0
7495
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...
0
5627
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,...
1
5052
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...
0
4707
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...
0
3193
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...
1
766
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
418
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...

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.