This might be a silly question but I couldn't find a good answer in the docs or anywhere.
If I use struct to define a binary structure, the struct has 2 symmetrical methods for serialization and deserialization (pack and unpack) but it seems ctypes doesn't have a straightforward way to do this. Here's my solution, which feels wrong:
fr...
I think the question is clear.
...
I have a list of structures and I want to delete some of them. I don't want to leave any empty space where the structures are deleted. I tried it with this code, but it didn't work.
struct symtab *sp;
for(sp = symtab; sp < &symtab[NSYMS]; sp++)
if(sp->scope == scope) // delete
{
sp = sp+1;
...
I am trying to resolve a TimeSpan using Unity. Executing the container Resolve call results in a FatalExecutionEngineError.
FatalExecutionEngineError was detected
Message: The runtime has encountered a fatal error. The address of the error was at 0x543c3dc8, on thread 0x1bb8. The error code is 0xc0000005. This error may be a bug i...
Hi
I using some old API and need to pass the a pointer of a struct to unmanaged code that runs asynchronous.
In other words, after i passing the struct pointer to the unmanaged code, the unmanaged code copies the pointer and returns immediately. The unmanaged code can access that struct in background, in another thread. I have no contr...
I'm trying to create a static struct in C++:
static struct Brushes
{
static HBRUSH white ;
static HBRUSH yellow ;
} ;
But its not working, I'm getting:
Error 4 error LNK2001: unresolved external symbol "public: static struct HBRUSH__ * Brushes::white"
Why?
The idea is to be able to use Brushes::white, Brushes::yellow through...
Task:
Application written in Delphi accepts a structure (record in terms of Delphi) of three fields. I can send the pointer of this structure using SendMessage (Win32api) function.
So a question is:
How to maintain certain structure representation in memory for delphi in terms of delphi. It has type
PWPModPostData = ^ TWPModPostDat...
I am trying to send my struct over a UDP socket.
struct Packet {
int seqnum;
char data[BUFFERSIZE];
};
So on the sender I have
bytes = sizeof(packet);
char sending[bytes];
bzero(sending, bytes);
memcpy((void *) sending, (void *) &packet, sizeof(bytes));
bytes = sendto(sockfd, sending, sizeof(sending), 0,
(struct sockaddr *...
I am trying to call a function in a unmanaged C++ dll.
It has this prototype:
[DllImport("C:\\Program Files\\MySDK\\VSeries.dll", EntryPoint = "BII_Send_Index_Template_MT" )]
internal unsafe static extern Int32 BII_Send_Index_Template_MT(IntPtr pUnitHandle, ref BII_Template template, Int32 option, Boolean async);
BII_Template tem...
I'm usign C# with P/Invoke to acces to a dll method. The definition of the method is the following:
[DllImport("userManager.dll")]
static extern int GetUsers(out IntPtr userList);
And the struct layout I've done is the following:
[StructLayout(LayoutKind.Sequential)]
public class USER_LIST
{
public uint NumUsers;
...
Is it possible to iterate of a C struct, where all members are of same type, using a pointer. Here's some sample code that does not compile:
#include <stdio.h>
#include <stdlib.h>
typedef struct
{
int mem1 ;
int mem2 ;
int mem3 ;
int mem4 ;
} foo ;
void my_func( foo* data )
{
int i ;
int* tmp = data ; // This ...
Hi.
Studing STL I have written a a simple program to test functors and modifiers. My question is about the difference aon using CLASS or STRUCT to write a functor and try to operate on it with function adaptors.
As far as I understand in C++ the difference beetween CLASS and STRUCT is that in the last case the members are public by defau...
Is there an easier way to display the struct fields and their corresponding values in RichEdit control?
This is what I am doing now:
AnsiString s;
s = IntToStr(wfc.fontColor);
RichEdit1->Lines->Append(s);
etc...
Is there an easier way than having to individually call each one? I want to read a binary file and then display the corre...
Even though I am a long time C programmer, I only recently learned that one can directly assign structure variables to one another instead of using memcpy:
struct MyStruct a,b;
...
a = b; /* implicit memcpy */
Though this feels a bit "high-level" for C, it is definitely useful. But why can't I do equality and inequality comparison:
i...
I am working with a 2-dimensional array of structs which is a part of another struct. It's not something I've done a lot with so I'm having a problem. This function ends up failing after getting to the "test" for-loop near the end. It prints out one line correctly before it seg faults.
The parts of my code which read data into a dummy ...
Say for n=5, the following code gives me a plot for n randomly generated nodes. These nodes are not structures (just plotted points), but I want to assign every node a message just as I did for sink and source and keep track of the nodes identity and location.
For example, if node 4 has (x,y) coordinates (.3452 , .5463), I want to assig...
class Newstring
{
public:
Newstring();
void inputChar ( char);
void display ();
int length ();
void concatenate (char);
void concatenate (Newstring);
bool substring (Newstring);
void createList ();
Node * getHead (); // error
private:
struct Node
{
char item;
Node *next;
};
N...
As helped by gnovice I got following code, but now I want to assign energy (randomly) to every nodes using E=floor(rand(1)*10) and also want to compare for maximum energy and what is distance between them?
N=input('no. of nodes : '); %# Number of nodes
coords = num2cell(rand(N,2)) %# Cell array of random x and y coordin...
In C I have an array of structs defined like:
struct D
{
char *a;
char *b;
char *c;
};
static struct D a[] = {
{
"1a",
"1b",
"1c"
},
{
"2a",
"2b",
"2c"
}
};
I would like to determine the number of elements in the array, but sizeof(a) returns an incorrect resu...
I have a function in C# that is passing an array of structures into a DLL written in C++. The struct is a group of ints and when I read out the data in the DLL all the values come out fine. However if I try to write to the elements from C++ the values never show up when I try to read then back in C#.
C#
[StructLayout(LayoutKind.Sequent...