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

Can we define a struct with out any elements in it? for example...

Expand|Select|Wrap|Line Numbers
  1.  typedef struct test1 test2;
  2.  
  3. int main(int argc,char **argv)
  4. {
  5.  test2 *x; /*This works*/
  6.  test2  y; /*This doesn't work */
  7. }
  8.  
  9.  
What does an empty struct mean ?
Mar 18 '11 #1
2 1954
Banfa
9,065 Expert Mod 8TB
You can in C++ not in C but you need to use { }.

I could be used as the base class for a class hierarchy.
Mar 18 '11 #2
donbock
2,426 Expert 2GB
In C, you are not defining an empty structure; instead, what you have is an incomplete structure definition. An incomplete structure definition can be used in any context where you don't access anything inside the structure or need to know the size of the structure. Typically, an incomplete structure definition is used to create pointers to the structure, typedef synonyms for the structure, or self-referential structures.
Mar 18 '11 #3

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

Similar topics

2
by: Michael Sgier | last post by:
Hello what's going on here and some basic questions: - define...unfortunately i haven't found it in my book so what exactly does this? - then SKYBOXVERTEX is declared...i understand the first...
3
by: Mark A. Odell | last post by:
If I have a structure that may point to a volatile "region (e.g. device)" or a context in memory what would be the best way to use the volatile keyword? E.g. a) volatile on struct objects ...
4
by: rmsprm | last post by:
I have run across the following syntax in a C file - if(funcAbc(paramXyz).mem2 == PASS) { .... } I have never seen this syntax before, is it ANSI C or just something the Greenhills toolset...
1
by: Rick | last post by:
I would like to be able to access the members of a struct (or class) based on their order within the struct. For example, say I had a struct something like: public struct PhoneTypes { public...
1
by: [Yosi] | last post by:
How I define the following C struction in C# typedef struct _T_Edit { char Name; char EditBox; } T_Edit; the struct member is : char Name;
3
by: aiooua | last post by:
hello, Is the following code proper? ----- typedef int one_data; typedef long two_data; typedef struct one_{ char *name; one_data info;
2
by: enliteneer | last post by:
I have an array of structures (my own typedef) that I wish to pass to a function. Since the array with the structs is rather large, I would like to pass a pointer to just the first element and...
2
by: ice88 | last post by:
i have problem in define struct within struct struct student_detail { int id; string name; }; struct subject_detail
1
by: Polaris | last post by:
Hi Experts: In my C# program I need to use a Win32 DLL which leads to a question: how to define Win32/C++ struct with array in C#. For example, I have a C++ struct: struct MY_STRUCT { int ...
3
by: syang8 | last post by:
If I have a struct S { int a; float b; }; how to initialize a static array of S?
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: 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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.