typedef struct foo
{
bool my_bool;
int my_int;
} foo;
In the example above I understand that my_bool will be initialized randomly to either true or false but what about my_int? I assumed that my_int would be default initialized to 0 but that seems not to be the case.
Defining structs in this way appears to be incompatible wit...
OK, I'm in a dilemma right now, and neither my knowledge of C (which isn't the biggest one anyways) nor the almighty Google seem to be able to help me with this:
I have some structures for a game prototype:
Map (Uhhm... the Map..)
Chara (A base for Enemies the Players)
Player (The Player)
Now the problem is: Map needs a refere...
I have a struct defined in a header as follows:
#define LC_ERR_LEN 300
typedef struct dLC_ERRMSG {
short nr;
short strategy;
char tx[LC_ERR_LEN];
} LC_ERRMSG;
Which I use in my code as such:
LC_ERRMSG err;
char *szError;
szError = strerror(sStatus);
snprintf(err.tx,LC_ERR_LEN," %s - %s",szFilename,szError);
/* do something w...
Hi there, I have a struct
struct myStruct {
Dictionary<string, int> a;
Dictionary<string, string> b;
......
}
I want to create a arraylist of that struct
ArrayList l = new ArrayList();
myStruct s;
s.a.Add("id",1);
s.b.Add("name","Tim");
l.Add(s);
However, I got the error "Object reference not set to an instance of an...
Given a record type:
TItem = record
UPC : string[20];
Price : Currency;
Cost : Currency;
...
end;
And the name of a field as a string, how can I get the offset of that field within the record? I need to do this at runtime - the name of the field to access is decided at runtime.
Example:
var
pc : Integer;
fieldName...
I have this code and I am not getting the expected results... whats wrong?
typedef struct {
int data1;
int data2;
}t;
void foo(int a, int b) {
Handle handle;
t arg;
arg.data1 = a;
arg.data2 = b;
handle = (HANDLE) _beginthread( myFunc, 0, (void*) &arg);
}
void myFunc(void *param) {
t *args = (t*) param;
int ...
I have the following code and when I run it, passing 1000 bytes to the parameter in the function, the structure MEMORY_BASIC_INFORMATION has none of its variables used, they all stay the value 0. I wondered if that is supposed to be?
public unsafe static bool CheckForSufficientStack(long bytes)
{
MEMORY_BASIC_INFORMATION stackInfo ...
How do I force const-ness of the memory pointed to by obj->val1 in the function fn?
#include <iostream>
struct foo {
int* val1;
int* val2;
int* val3;
};
void fn( const foo* obj )
{
// I don't want to be able to change the integer that val1 points to
//obj->val1 = new int[20]; // I can't change the pointer,
*...
I'm trying to get a sub-string for each member of the struct 'structs' and then assign that sub-string to a new member of the temp_struct.
The problem I'm having is how to free the sub-string on each iteration, for some reason the code runs, however valgrind throws an Invalid read of size 1, which I assume I'm reading off the block of m...
Im looking at namespaces and i dont really see a difference between these and classes.
im teaching myself c++ ive gotten several books online, so i know im not learning the
most effectively. anyways can someone tell me the difference between the two and what would be the best time to use a namepace over a class. also i dont see much ab...
I have any array of structs. Each struct in the array has the following attributes:
user_id
num_hot_dogs_eaten
date_last_pigged_out
Here's what I want to do:
Find the structs with matching user_id's, and merge them into one struct record where num_hot_dogs_eaten is the sum of all matching records and date_last_pigged_out is the m...
I define a std::map in static library .a like this
//////////////////////////////////////
#import <map>
class CCImage;
class ImageArray{
std::map<int,CCImage*> mapCCImages;
private:
int imagesLength;
public:
ImageArray();
~ImageArray();
int getImageLen();
bool addCCImage(int key,CCImage * texture,bool replace = true);
CCImage *g...
what is mean by slack byte in structures in C. please help.
...
Is there any performance overhead that you take on when using Structs (as compared to Arrays, Hashes, etc.) in Ruby?
...
Hey there,
for a little project i wanted to use a struct with an stl container in it.
This thingy is then packet into a dynamic 2 dim. array, but when i try to delete it,
it segfaults.
Here is the code:
struct cell{
list<pair<double, double> > alist;
};
int main()
{
struct cell ** myAr = new cell*[5];
for(int i = 0; i < 5; ...
out.write( struct.pack(">f", 1.1) );
out.write( struct.pack(">i", 12) );
out.write( struct.pack(">3s", "abc") );
how to import struct package in java it says ..
no package found when i am trying to execute it
so kindly tell me any suggestions if any
Thanking you
i took that code from
http://stackoverflow.com/questions/1255918/...
For classes, == and != uses object.ReferenceEquals. But for structs, == and != is not defined.
struct S { }
S s1 = new S();
s1 is ValueType; // true
S s2 = new S();
object.Equals(s1, s2); // true
s1 == s2; // operator '==' cannot be applied.
The default behavior for ValueType equals is reflecting over all fields and checking equality,...
Hi I have the following union which is part of a larger struct and I want to store a uint64_t (64 bits size) data in this union. However i want to store it by accessing the id_data field since the others are not large enough for a complete uint64_t. But i dont know how to assign my uint64_t data into this id_data field.
I know how to ...
Is there any function equivalent to Python's struct.pack in Java that allows me to pack and unpack values like this?
pump_on = struct.pack("IIHHI", 0, 0, 21, 96, 512)
...
These are functions and Struct declarations I have, and I'm not allowed to change them.
DerivedA giveDerivedA ();
DerivedB giveDerivedB ();
struct Base{
QString elementId;
QString elementType;
};
struct DerivedA : Base {
int a;
int b;
};
struct DerivedB : Base {
int c;
int d;
};
But what I need is something ...