If I have a source.c file and it uses a structure like
struct a
{
int i;
struct b
{
int j;
}
};
if this structure is to be used by some other file func.c how to do it?
shall we open a new header file and declare the structure there and include that header in the func.c?
or can we define the total structure in ...
I am trying to use Python's ctypes library to access some methods in the scanning library SANE. This is my first experience with ctypes and the first time I have had to deal with C datatypes in over a year so there is a fair learning curve here, but I think even without that this particular declaration would be troublesome:
extern SANE...
Can anyone provide me a very good tutorial for structures in C?
I have made google search, but I find normal information. I am looking for structures in detail. Kindly let me know. Thanks
...
Hi, I have created a couple of different structures in a program. I now have a structure with nested structures however I cannot work out how to initalize them correctly.The structures are listed below. Btw, thanks in advance for reading my post or posting an answer :-) :
/***POINT STRUCTURE***/
struct Point{
float x; //x ...
Hello,
I'm trying to translate the following code from C++ to C#
`
struct tPacket
{
WORD size;
WORD opcode;
BYTE securityCount;
BYTE securityCRC;
}
...
static char data[8192] = {0};
tPacket * packet = (tPacket *)data;`
so far I've come up with:
C#
public struct tPacket
{
public ushort size;
public ushort opcode;
public byte sec...
I tend to use ArrayLists of structures. It is then very easy to cycle through the list with a foreach.
The problem I have is I cant use a foreach to modify the structures contents and have to use a for and messy typecasts.
((dataStructure)files[x]).name = here;
Is there a tidier way to do it?
...
Hey everyone!
Could someone please help me understand this error in C for structures?
This is my code:
struct Orientation
{
char facing;
char sensor;
char mazeDir;
};
struct Orientation O[16];
O[0] = {'N', 'F', 'N'};
O[1] = {'N', 'B', 'S'};
O[2] = {'N', 'R', 'E'};
O[3] = {'N', 'L', 'W'};
O[4] = {'S', 'F', 'S'};
O[5] = {'S'...
Is there a data structure (readily available in STL or boost), that accepts two arguments and maps it to a certain value?
Examples would be for returning certain information in a coordinate grid or getting the weight of an edge in a graph:
coordinate_quadrant(-1,-1) = 3
weight_of(u,v) = 10
The quadrant example could be done i...
I have been looking at some sites that pretend that there is a directory structure in the URL and wondered 'how?'.
I am taking control of a website at work and have looked over the code. They have a database for all the pages and they are created dynamically.
I can get the homepage working on my local server but i dont have a clue as...
How do I put a struct in a separate file? I can do it with functions by putting the function prototype in a header file e.g. file.h and the function body in a file like file.cpp and then using the include directive #include "file.h" in the source file with main. Can anybody give a simple example of doing the same thing with a structure l...
I'm trying to create the following structure:
[StructLayout(LayoutKind.Explicit, Size=14)]
public struct Message
{
[FieldOffset(0)]
public ushort X;
[FieldOffset(2)]
[MarshalAs(UnmanagedType.ByValArray, SizeConst=5)]
private ushort[] Y;
[FieldOffset(12)]
public ushort Z...
In VB.NET, why can't I see a member of a structure when I make it a nullable type?
Example:
Public Structure myNullable
Dim myNullVar As Integer
End Structure
Sub Main()
Dim myInstance As myNullable 'This works.
Dim myNullableInstance? As myNullable 'This works.
myInstance.myNullVar = 1 'This works.
...
Ok, what the heck am I doing wrong here..
"System.TypeLoadException: Cannot marshal field 's2' of type 'MY_Struct1': The type definition of this field has layout information but has an invalid managed/unmanaged type combination or is unmarshalable."
'VENDORAPI short FunctionEx(Struct1* pstruct1);
Declare Auto Function FunctionEx Lib "...
Is there any way to emulate a structure class in PHP? ie a class which passes by value and not by reference, so it can still be type hinted...
And if so, what different techniques could be used? What's the best technique?
If this is possible you could obviously create a fully type safe layer for PHP, are there such layers? Has anyone h...
#include<stdio.h>
#include "amicablenumber.h"
int i,j;
struct amicable
{
int **amicablePair;
int size;
};
main()
{
int startnum = 250;
int endnum = 1000;
struct amicable* ami;
ami = getAmicablePairs(startnum, endnum);
printf("{");
for(int i = 0; i<ami->size; i++)
{
printf("{%d, %d}",ami->amicablePair[i][0], ami->amicab...
Duplicate of: When to use struct in C#?
Are there practical reasons to use structures instead of some classes in Microsoft .NET 2.0/3.5 ?
"What is the difference between structures and classes?" - this is probably the most popular question on intrviews for ".NET developer" vacancies. The only answer that interviewer considers to be rig...
Hi,
I have to develop a code which will store a list of objects, as example below
101, value 11, value 12, value 13 ...etc
102, value 21, value 22, value 23 ...etc
103, value 31, value 32, value 33 ...etc
104, value 41, value 42, value 43 ...etc
Now, the difficulty is, that first column is an identifier, and whole table should alwa...
void selectionSort(int array[], int n)
{
for(int x=0; x
is this function written correct..?
...
I've written a tic tac toe code that fine to a point. I have Alpha-Beta Pruning working also. I've ran across a problem that I need ideas, NOT CODE. How can I choose a move that will win in 4 moves versus a move that will win in 8 moves. The problem I'm having is the branch that returns a optimal score from minimax/AB prunning will possi...
Hi all,
Not sure if this has been asked before, did some digging. I'm trying to prepare for a few interviews, and I was just curious to see if how Java implements its data structures (arraylist, map), etc is public.
Thanks.
...