Hi!
I am relatively new to C++ and am having problems understanding struct.
I have a struct declared as follow
struct MyNode {
int level;
int index;
MyNode children[4];
}
However the code fails to compile and reports error C2148: total size of array must not exceed 0x7fffffff bytes.
But the following code compiles
stru...
I have been trying to understand the use of "primitives" in Java and C# and the difference between them (if any). I have asked a series of questions on SO and some of the answers seem to confuse the issue rather than clarify it. Some answers (and some MS documentation) appear to provide contradictory statements. From SO
http://stackove...
I found some struct initialization code yesterday that threw me for a loop. Here's an example:
typedef struct { int first; int second; } TEST_STRUCT;
void testFunc() {
TEST_STRUCT test = {
second: 2,
first: 1
};
printf("test.first=%d test.second=%d\n", test.first, test.second);
}
Surprisingly (to me), here's the...
The following code works, but I can't figure out what's going on memory-wise. Where and how is the struct value t copied?
interface ITest { void Hello(); }
struct STest : ITest
{
public void Hello() { Console.WriteLine("Hello"); }
}
static ITest Make()
{
STest t = new STest();
return t;
}
static void Main(string[] arg...
I recently created a generic Matrix<T> class that acts as a wrapper around a List<List<T>> collection. As far as I can tell, this class is working perfectly. I am running into a slight problem though regarding the default values of the T's.
I create an instance of Matrix<int>(3, 3), which creates a 3x3 matrix of ints, all defaulted to 0...
Hi, I need to send a C struct over the wire (using UDP sockets, and possibly XDR at some point) at a fairly high update rate, which potentially causes lots of redundant and unnecessary traffic at several khz.
This is because, some of the data in the struct may not have changed at times, so I thought that delta-encoding the current C str...
How can I tell Doxygen to use the first declaration in this code:
typedef struct _decor_extents {
int left;
int right;
int top;
int bottom;
} decor_extents_t;
Cheers,
Kris
...
I tried to compile the following code, but the compiler wouldn't doing because " * is illegal for a struct" is that true?
struct String {
int length;
int capacity;
unsigned check;
char ptr[0];
} String;
void main(){
char *s;
String *new_string = malloc(sizeof(String) + 10 + 1);
}
...
Let's say we have an array of PRINTER_INFO_2 like this:
PRINTER_INFO_2* printers = (PRINTER_INFO_2*)malloc(sizeof(PRINTER_INFO_2) * 64); // room for 64 items
Then we call EnumPrinters() to get a list of locally installed printers:
EnumPrinters(
PRINTER_ENUM_LOCAL,
NULL,
2,
(LPBYTE)printers,
...);
Here's the stru...
I'm writing a .SO that gets called by another program and I want to be able to flip a value in memory through a function in the .SO
What I have so far is :
int
axptrace( int numArguments, char* pMessageBuffer, int* pMessageBufferSize,
char* pData[], int* pDataLength[] )
{
printf("Beginning dump attempt..\n");
unsigned int* wkp...
For performance reasons I use structs in several use cases.
If I have an object or a nullable type (another struct but nullable) as a member in the struct, is there an adverse effect on performance. Do I lose the very benefit I am trying to gain?
Edit
I am aware of the size limitations and proper use of structs. Please no more lectur...
It was recently asked how to do a file slurp in python:
link text
And it was recommended to use something like
with open('x.txt') as x: f = x.read()
How would I go about doing this to read the file in and convert the endian representation of the data?
For example, I have a 1GB binary file that's just a bunch of single precision flo...
I am trying to get a C# WPF application to communicate with another application written in C using WM_COPYDATA. The C app is trying to send a struct as follows:
typedef struct
{
int x;
int y;
char str[40];
double d;
char c;
} DATASTRUCT;
In my C# app I have defined a struct as follows:
[StructLayout(LayoutKind.Seq...
Based on http://alexreg.wordpress.com/2009/05/03/strongly-typed-csv-reader-in-c/, I created a DLL which can read different file types. I also have unit tests that run successfully. I create a struct and use it as the generic type.
Anyway, when I compile, I get a warning on each of the struct fields. For example: field 'FileReader.Tes...
There have been several questions over the past few days about the proper use of null; here are three (one is mine):
Best Practice: Should functions return null or an empty object?
null objects vs. empty objects
how do i explain that if (xyz == null) checks are not “protective”.
While reading and thinking about this issue, the though...
Hi,
I am currently working on a small tokenizer template function which also casts the tokens to different objects. this works really nice aslong as all the strucs I cast to have the same number of items. what I would like to do know is to make the function cast to structs with any number of items. The bottleneck of the function for me ...
Okay, I have something like this in C++:
class MyClass{
private:
int someVariable;
int someOtherVariable;
struct structName{
int someStructVariable;
int someOtherStructVariable;
};//end of struct
public:
//getters & setters for the defined variables.
int getSomeStructVariable()
{
// this does not work I get ...
Suppose struct_name is the name of a struct I've defined, and array is a member in the struct defined as char array[o]
what does the following line produce? (*struct_name).array
an address location?
...
Hello,
I am working on an application that builds a vector of structs for items in a given directory and returns a reference of the vector for it to be read, I receive the following errors when attempting to compile the example code below:
1. 'class std::vector<indexStruct, std::allocator<indexStruct> >' has no member named 'name'
2. n...
Below is the header file.can anyone please give a idea to call the callback function below.
//Function Prototype
int PASCAL EXPORT RegisterCallbackFunctions (TCallbacks CallbackFuncs);
//Data Structure
struct TCallbacks
{
LPONUSSDREQUEST m_pOnRequest;
LPONUSSDRESPONSE m_pOnResponse;
};
struct TData
{
DWORD m_dwCmd;
BYTE ...