I am working on a homework assignment for a class. The problem statement says to use the data definition:
(define-struct diff-exp exprs)
(define-struct mult-exp exprs)
;; An Expr is one of
;; -- Number
;; -- (make-diff-exp (cons Expr LOExpr))
;; -- (make-mult-exp (cons Expr LOExpr))
;; Interpretation: a diff-exp represents a difference,...
I have a structure containing character arrays with no any other member functions. I am doing assignment operation between two instances of these structures. If I'm not mistaken, it is doing shallow copy. Is shallow copy safe in this case?
I've tried this in C++ and it worked but I would just like to confirm if this behavior is safe.
...
I've written a program to probe the limits of a system's C time.h functions and dump them out in JSON. Then other things which depend on those functions can know their limits.
# system time.h limits, as JSON
{
"gmtime": { "max": 2147483647, "min": -2147483648 },
"localtime": { "max": 2147483647, "min": -2147483648 },
"mktim...
Some C++ compilers permit unnamed unions and structs as an extension to standard C++. It's a bit of syntactic sugar that's occasionally very helpful.
What's the rationale that prevents this from being part of the standard? Is there a technical roadblock? A philosophical one? Or just not enough of a need to justify it?
EDIT: Sorry, ...
typedef struct _stats_pointer_t
{
char **fileNames;
stats_t stats;
} stats_pointer_t;
I need to fill 'fileNames'. Basically, I need to mimic this functionality:
char *fileNames[argc - 1];
fileNames[0] = argv[0];
... but using the struct stats_pointer. So I need to declare the struct, then probably allocate memor...
I want to know how to read a struct within a struct via php's unpack function. When I get an IS_MCI packet, I check it's Type to make sure it's equal to ISP_MCI, and then I check NumC to find out how many CompCar structs there are within this packet. The problem is trying to unpack these contents into an array via a single function. I al...
hi want to access from bean object in jsp page .how to get that.pls help asap.
1)i have formbean class with customername,date,amount,rate etc with setter() and getter() for the field menmbers.
2) i have dataaccess class where i can get data for the bean calss property from database and set data to formbean class object like
class formb...
I am trying to call an unmanaged C++ function, that has a structure as an input parameter.
The structure is defined in the header file like this:
struct MyStruct
{
int siOrder;
char aaszNames[6][25];
int siId[6];
int siTones[6];
};
I tried to declare the managed struct as following:
[StructLayoutAttribute(Layo...
GCC gives me an "array type has incomplete element type"-error message when i try to compile this:
typedef struct _node node;
struct _node{
int foo;
node (*children)[2];
int bar;
};
In memory the struct should look like this
0x345345000000 foo
0x345345000004 pointer to 1. child node
0x345345000008 pointer to 2. child node
0x345345...
Hi!
This coulde be a dumm question, but i can't figure it out what i am doing wrong( i haven't used two structures in each other ).
I have two structures:
struct test
{
struct ddata* difference;
int diff;
};
struct test *MSG;
struct ddata
{
char *filename;
char *size;
};
struct ddata *difference
And i want to giv...
I have made a structure for ints and pointers etc. as might be used in LISP.
A pointer is at least 8-byte aligned so tag=0.
An integer is 29 bits and has a tag of 1.
Other types have different tag values.
struct Atom{
union{
Pair *pair;
struct{
unsigned tag :3;
union{
int ...
Hello, this is my first time posting a question here - I've searched for ones that are similar, but none came up that I found.
Here is the snippet from my header:
#define LINE_LEN_MAX 256
typedef struct line_description {
char buffer[LINE_LEN_MAX + 1];
[...]
} line;
And here is the snippet from my main function:
int main(in...
For a Type, there is a property IsClass, but how to know a Type is a Struct?
Sorry, I have to add some more information.
I am using C#.
Although IsValueType is a necessary condition, it is obviously not enough. For an Integer is a value type also.
...
I have next code:
static void Main(string[] args)
{
byte currency;
decimal amount;
if (Byte.TryParse("string1", out currency) && Decimal.TryParse("string2", out amount))
{
Check(currency, amount);
}
Check(currency, amount); // error's here
}
static void Check(byte b, decimal d) { }
and ge...
I recently debugged a strange C++ problem, in which a newly declared vector somehow had a size of 477218589. Here's the context:
struct Triangle {
Point3 a,b,c;
Triangle(Point3 x, Point3 y, Point3 z) : a(x), b(y), c(z) {}
Vector3 flat_normal() { return (a-c)^(b-c); }
};
vector<Triangle> triangles;
Calling triangles.size()...
For a Type, there is a property IsClass in C#, but how to decide a Type is a struct?
Although IsValueType is a necessary condition, it is obviously not enough. For an Integer is a value type also.
Someone suggests the following code:
bool IsStruct=type.IsValueType && !type.IsEnum && !type.IsPrimitive;
But I am not sure whe...
Hello all, I have a function in C++ that I exported to a DLL. I contains a struct pointer as one of the parameters. I need to use this function in C#, so I used DLLImport for the function and recreated the struct in C# using StructLayout. I've tried passing in the parameter using ref as well as tried Marshaling it in using MarshalAs(U...
I have two questions, actually. But they are very closely related.
Suppose I have a simple struct like this:
public struct TradePrice {
public float Price;
public int Quantity;
public TradePrice(float price, int quantity) {
Price = price;
Quantity = quantity;
}
}
Question 1
Now if I have code somewhe...
Just wondering why we need struct if class can do all struct can and more? put value types in class has no side effect, I think.
EDIT: cannot see any strong reasons to use struct
A struct is similar to a class, with the following key differences:
A struct is a value type, whereas a
class is a reference type.
A struct does not support...
if you have a struct consisting of complex data items. Can you assign one instance to another.
struct Test t1;
struct Test t2;
t2=t1;
i have seen that it works for simple structures, does it work for Complex structures?. How does the compiler know how to copy data items depending on their type, eg differentiating between an int and st...