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.

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, use the tag indicated:

  • 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/C++ family of languages used to indicate a structures record.
6110 questions
243
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
  • 4,584
  • 6
  • 27
  • 37
127
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
  • 23,639
  • 42
  • 138
  • 202
125
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
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,388
  • 11
  • 58
  • 87
73
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
  • 8,261
  • 10
  • 62
  • 98
72
votes
12 answers

Struct Inheritance in C

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

uml classdiagram constructor with parameters

I am a complete ROOKIE at this so I need some help on it. How would you create uml class diagram and constructors with parameters. for default (no parameters) you do policyholder() for diagram and pseudo-code for parameters would you do the same…
blake
  • 591
  • 1
  • 5
  • 9
55
votes
7 answers

c++ vector last element field

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,045
  • 4
  • 13
  • 17
54
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
  • 823
  • 2
  • 9
  • 19
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
  • 32,727
  • 31
  • 131
  • 208
51
votes
3 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,147
  • 3
  • 21
  • 28
48
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
  • 505
  • 1
  • 4
  • 3
45
votes
2 answers

Best algorithm for efficient collision detection between objects

I'm confused. Well not confused, so much as not wanting to do 6 test programs to see which algorithm is the best. So I thought I'd ask my expert friends here at SO to give me the benefit of their experience. The scenario is a 3d scene with…
Robinson
  • 8,836
  • 13
  • 64
  • 108
45
votes
18 answers

Good practices in writing MATLAB code?

I would like to know the basic principles and etiquette of writing a well structured code.
user238469
44
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,385
  • 3
  • 12
  • 11
1
2 3
99 100