Linked Questions

41 votes
6 answers
269k views

Here's initialization I just found in somebody else's question. my_data data[]={ { .name = "Peter" }, { .name = "James" }, { .name = "John" }, { .name = &...
zubergu's user avatar
  • 3,725
13 votes
3 answers
1k views

How can I initialize a structure if one field in the structure is itself a structure?
0xAX's user avatar
  • 22k
6 votes
2 answers
3k views

Is it possible to statically initialise part of a struct? The stuct I have: struct data { char name[20]; float a; int b; char c; }; When initialsing and printing: struct data ...
user avatar
2 votes
3 answers
6k views

typedef struct foo{ void (*del)(void *toDel); char* (*p)(void *tp) } Foo; Foo init(char* (*print)(void*),void (*delFunc)(void*)); Trying to figure out how to assign or initialize the supplied ...
waffles's user avatar
  • 91
0 votes
1 answer
2k views

Possible Duplicate: How to initialize a struct in ANSI C I have a global variables in my code with initial values , which are : int init = 0; int flag = FALSE; sem_t *mutex; char * ptr1 = NULL; ...
JAN's user avatar
  • 22.1k
0 votes
2 answers
759 views

Is there a way to declare a structure with default initalisation values? I have a header file which defines a structur like this: typedef struct struc_s { size_t cost const = 2000; size_t ...
dhein's user avatar
  • 6,543
-1 votes
3 answers
476 views

I have built the following C example trying to simulate simplistic generic driver code which can be used in small ARM micro-controllers: #include <stdio.h> #include <string.h> typedef ...
nobody's user avatar
  • 11
1 vote
1 answer
199 views

I wonder if there is a way to initialize a member of a member of a struct. Let`s say I have 2 structs, t1 and t2. t2 contains 2 instances of t1. like this: typedef struct t1{ int ...
user avatar
-1 votes
2 answers
190 views

typedef struct { char fielda[ 2 ][ FIELD_A_MAX + 1 ]; bool fieldb = false; bool fieldc = false; sem_t fieldd; } Set; I get the error: error: expected ‘:’, ‘,’, ‘;’, ‘}’ or ‘__attribute__’ ...
der_Fidelis's user avatar
  • 1,515
1 vote
0 answers
213 views

I am getting the error identifier "character" is undefined. I have included the header file as well and still cannot figure out the reason behind it. The screen shot of the error The print....
-1 votes
2 answers
135 views

typedef struct{ int num, den; } tfrac; tfrac multf(tfrac a, tfrac b); tfrac multf(tfrac a, tfrac b){ tfrac res; res={a.num*b.num, a.den*b.den}; //The ERROR is here return res; } This program ...
Alex Hernandez's user avatar
0 votes
1 answer
157 views

I want to initialise a const struct: const struct MyStruct MYSTRUCT_DEFAULTS = { "prop1", "prop2", "prop3", 123, 456, ... } However in the above it is impossible to tell which field is ...
Flash's user avatar
  • 16.9k
1 vote
1 answer
107 views

Trying to initialize structure variable fields with values in short way: typedef struct { int id = 0; char* name = "none"; }employee; employee e = { .id = 0 ; .name = "...
vico's user avatar
  • 18.5k
0 votes
0 answers
53 views

Can someone tell me the name for assigning functions like this in C - .pr_type = SOCK_SEQPACKET, .pr_domain = &inetdomain, .pr_protocol = IPPROTO_SCTP, .pr_flags =...

15 30 50 per page
1
2 3 4 5 6