Questions tagged [structure]

Structure is a fundamental, tangible or intangible notion referring to the recognition, observation, nature, and permanence of patterns and relationships of entities. DO NOT USE this tag for C or C++ struct questions!

A structure can be a:

  • A structure in mathematical logic: in universal algebra and in model theory, a structure consists of a set along with a collection of finitary operations and relations which are defined on it.

  • The structure of a program

For the following topics, use different tags as indicated below:

  • A : a particular way of storing and organizing data in a computer so that it can be used efficiently.
  • A (short for "structure") is a keyword in the C and C++ languages, used to indicate a structures record.
6561 questions
318
votes
11 answers

Structure padding and packing

Consider: struct mystruct_A { char a; int b; char c; } x; struct mystruct_B { int b; char a; } y; The sizes of the structures are 12 and 8 respectively. Are these structures padded or packed? When does padding or packing take place?
Manu
  • 5,534
  • 6
  • 32
  • 42
142
votes
3 answers

How to declare a structure in a header that is to be used by multiple files in c?

If I have a source.c file with a struct: struct a { int i; struct b { int j; } }; How can this struct be used in another file (i.e. func.c)? Should I create a new header file, declare the struct there and include that header in…
Manoj
131
votes
5 answers

What's the need of array with zero elements?

In the Linux kernel code I found the following thing which I can not understand. struct bts_action { u16 type; u16 size; u8 data[0]; } __attribute__ ((packed)); The code is here:…
Jeegar Patel
  • 26,264
  • 51
  • 149
  • 222
95
votes
6 answers

What does a zlib header look like?

In my project I need to know what a zlib header looks like. I've heard it's rather simple but I cannot find any description of the zlib header. For example, does it contain a magic number?
unixman83
  • 9,421
  • 10
  • 68
  • 102
85
votes
8 answers

How can I get a field from the last element of a vector in C++?

I have a vector vec of structures. Such a structure has elements int a, int b, int c. I would like to assign to some int var the element c, from the last structure in a vector. Please can you provide me with this simple solution? I'm going circle in…
berndh
  • 1,355
  • 4
  • 14
  • 19
83
votes
12 answers

Struct Inheritance in C

Can I inherit a structure in C? If yes, how?
jimit
74
votes
1 answer

constructor with parameters in UML class diagram

How would you create an uml class diagram for constructors with parameters? For default constructors (no parameters) you do policyholder() for the diagram and in the pseudo-code For constructors with parameters would you do the same…
blake
  • 771
  • 1
  • 6
  • 9
74
votes
15 answers

How to increase my "advanced" knowledge of PHP further? (quickly)

I have been working with PHP for years and gotten a very good grasp of the language, created many advanced and not-so-advanced systems that are working very well. The problem I'm running into is that I only learn when I find a need for something…
Kerry Jones
  • 21,806
  • 12
  • 62
  • 89
66
votes
4 answers

Where should utility functions live in Django?

Where should utility functions live in Django? Functions like custom encrypting/decrypting a number, sending tweets, sending email, verifying object ownership, custom input validation, etc. Repetitive and custom stuff that I use in a number of…
mitchf
  • 3,697
  • 4
  • 26
  • 29
66
votes
6 answers

Can I define a function inside a C structure?

I am trying to convert some C++ code to C and I am facing some problems. How can I define inside a structure a function? Like this: typedef struct { double x, y, z; struct Point *next; struct Point *prev; void act() {sth. to do…
DCuser
  • 953
  • 2
  • 10
  • 21
58
votes
2 answers

Arrow Operator vs. Dot Operator

It seems to me that C's arrow operator (->) is unnecessary. The dot operator (.) should be sufficient. Take the following code: typedef struct { int member; } my_type; my_type foo; my_type * bar; int val; val = foo.member; val =…
remline
  • 605
  • 1
  • 6
  • 3
52
votes
6 answers

How do you structure i18n yaml files in Rails?

I started populating an en yaml file in Rails and I can already tell it will get messy and out of hand before too long. Is there a convention to keeping this file organized? So far I have this structure: language: resource: pages: # index,…
Mohamad
  • 34,731
  • 32
  • 140
  • 219
50
votes
2 answers

Netbeans - is it possible to see project source folders in a tree (hierarchical) view, rather then a flat view?

I have some huge NetBeans projects with many packages, sub-packages, sub-sub-packages .etc, and it gets very confusing seeing all these package folders in the flat layout that NetBeans shows.. e.g. a.b.c.d.e.f.g , a.b.c.d.d.e.f.h .etc .etc Is it…
José
  • 1,525
  • 3
  • 14
  • 12
50
votes
4 answers

What is predicate in C++?

Can you give some example or a link to a topic.
munish
  • 4,505
  • 14
  • 53
  • 83
48
votes
2 answers

View file structure in VS Code

One of the features I use frequently in PHPStorm is the Structure window, which shows me my file structure broken down into functions, classes, variables, etc . I'm checking out VS Code, and I don't see an option for that type of window anywhere. Is…
wonder95
  • 3,825
  • 8
  • 45
  • 74
1
2 3
99 100