Hi.
I'm trying to pass a struct from one object to another. I have the following code:
private void mainMenuStripNewProject_Click(object sender, EventArgs e)
{
frmNewProject frmNewProject = new frmNewProject(this);
if (frmNewProject.ShowDialog() == DialogResult.OK)
{
StructProjectSettings tem...
I have a struct with a callback function, the callback function needs a pointer to the structure in order to do its operation. How do I properly define these elements such that is will compile without warnings?
typedef struct {
// some fields required for processing...
int (*doAction)(struct pr_PendingResponseItem *pr);
} pr_P...
Why would I want to do this?
typedef struct Frame_s
{
int x;
int y;
int z;
} Frame_t;
Also if I want to create an object what do I use Frame_s or Frame_t?
...
Possible Duplicate:
What are the differences between struct and class in C++
http://www.cplusplus.com/reference/std/typeinfo/type_info/
I guess my "teacher" didn't tell me a lot about the differences between struct and classes in C++.
I read in some other question that concerning inheritance, struct are public by default... ...
I was wondering:
If I have structure definitions, for example, like this:
struct Base {
int foo;
};
struct Derived {
int foo; // int foo is common for both definitions
char *bar;
};
can I do something like this?
void foobar(void *ptr) {
((struct Base *)ptr)->foo = 1;
}
struct Derived s;
foobar(&s);
e. g. cast the void p...
Possible Duplicates:
Empty class in C++
What is the size of an empty struct in C?
I read somewhere that size of an empty struct in C++ is 1. So I thought of verifying it.
Unfortunately I saved it as a C file and used <stdio.h> header and I was surprised to see the output. It was 0.
That means
struct Empty {
};
int main(v...
In Win32 programming a handful of POD structs is used. Those structs often need to be zeroed out before usage.
This can be done by calling memset()/ZeroMemory()
STRUCT theStruct;
ZeroMemory( &theStruct, sizeof( theStruct ) );
or by value initialization:
STRUCT theStruct = {};
Although the two variants above are not equivalent in g...
If I have array of structs MyStruct[]:
struct MyStruct
{
float x;
float y;
}
And it's slower than if I do float[] -> x = > i; y => i + 1 (so this array is 2x bigger than with structs).
Time difference for 10,000 items compare each other (two fors inside) : struct 500ms, array with only floats - 78ms
I thought, that struct a...
In GCC, I'm able to do this:
(CachedPath){ino}
inode->data = (struct Data)DATA_INIT;
where:
struct CachedPath
{
Ino ino;
};
typedef int8_t Depth;
struct Data
{
Offset size;
Blkno root;
Depth depth;
};
#define DATA_INIT {0, -1, 0}
MSVC gives the following error for these kind of casts:
error C2143: syntax error : m...
Hi,
I'm creating a lookup table in C
When I define this:
typedef struct {
char* action;
char* message;
} lookuptab;
lookuptab tab[] = {
{"aa","bb"},
{"cc","dd"}
};
it compiles without errors but when I do something like this:
typedef struct {
char* action;
char* message[];
} lookuptab;
lookuptab tab[] = {
{"aaa", {"bbbb"...
Hi everybody,
thanks for your support for solving my previous problems. Now I'm studying self referential structures. I have written the following code:
#include <stdio.h>
int main()
{
system("clear");
struct node
{
int x;
struct node *next;
} p1;
printf(" \nthe address of node1 = %u",& p1);
printf(" \n\nthe size of node 1 = %d",...
I am using structs in my project in this way:
typedef struct
{
int str1_val1;
int str1_val2;
} struct1;
and
typedef struct
{
int str2_val1;
int str2_val2;
struct1* str2_val3;
} struct2;
Is it possible that I hack this definition in a way, that I would use only types with my code, like
struct2* a;
a = (struct2*...
Hello -
I have an iPhone app that used to use an array of several thousand small objects for its data source. Now, I am trying to make it use C++ Structs, to improve performance. I have written the struct, and put it in "Particle.h":
typedef struct{
double changeX;
double changeY;
double x;
double y;
}ParticleStruct;
The...
How to convert variable of 'struct' type to a matrix in Matlab?
How do we convert the q_yearly_w, in the code below, which is of type 'struct' to a matrix with which we can perform normal mathematical operations?
%# open the file
fid = fopen(Reportq_rwo);
%# read it into one big array, row by row
fileContents = textscan(fid,'%s','Deli...
I want the following struct as a class member, but I don't know the type of T, so I need "declare" the struct at runtime.
struct Chunk (T) {
string id;
T[][] data;
}
class FileBla {
this() {
Chunk !int ck; // need to be turned in a class member
}
}
Should be missing something easy.
...
I asked this a while ago on comp.std.c++ and got no reply.
I'm just going to quote my post there with little modification.
Is the last requirement of standard-layout classes, 9/6, necessary or useful?
A footnote explanation is provided:
This ensures that two subobjects that
have the same class type and that
belong to the sa...
I have an array of structs. Each struct has the following two attributes:
win %
# of wins
I want to sort the array of structs by win %; however, for only those structs with at least 3 wins.
Any suggestions?
...
Inside of this first step towards a bootstrapped scheme interpreter I find the following set of typedef, struct, union, and enum definitions:
typedef enum {FIXNUM} object_type;
typedef struct object {
object_type type;
union {
struct {
long value;
} fixnum;
} data;
} object;
In particular, I'm ...
Ok guys, we all know there are all lot of typedef/struct questions out there, but I feel this one is a bit of a mind bender.
I'm simulating the neighbor interactions of a crystal lattice using strictly C. I have a struct called "ball_struct" which I typedef'ed as just "ball". The struct contains a pointer to a list of ball_structs (sin...
Hi,
I'm looking to initialize a global array of stucts in C within the header file however it keeps complaining when compiling. Here's my struct
typedef struct
{
char input[100][100];
int count;
char name;
}INPUT;
extern INPUT[] global;
Thanks
...