30,774 questions
2
votes
1
answer
143
views
Trying to learn how getchar works
I am encountering a problem inside a while loop that is embedded in a for loop iterating through a struct of arrays. The issues I am coming across is before the array iterates again, I want to have ...
-1
votes
3
answers
123
views
sizeof operator appears to return wrong value for c type packed struct [duplicate]
Given the following C struct:
struct __attribute__((__packed__)) XIRControl
{
uint8_t command;
char code[19];
uint16_t error;
union codeData
{
struct rcvCommands
{
...
0
votes
0
answers
88
views
Why am I getting this error in my assembly program?
I'm making an assembly program that is supposed to get the mac address of the specified interface, however, when I try to assemble it, I get this error.
gethwaddress.s:12: warning: multi-line macro `...
-1
votes
3
answers
217
views
Can I declare a variable along with a pointer?
Can I declare a variable along with a pointer?
//like this
struct node n1,n2,n3,*start;
//or do i have to do it separately
struct node *start;struct node n1,n2,n3;
to declare variable alongside ...
2
votes
2
answers
196
views
derived class cannot call recursively inherited member functions C++
I'm making it using multi inheritance with a pair struct that contains
an index and the type of the element in a recursive structure like this:
template<int index, typename... ts>
struct ok;
...
1
vote
0
answers
71
views
Is it okay to leave a struct unnamed when using typedef? [duplicate]
I'm naming a struct type with typedef, and I've been using them like this
typedef struct {
double x, y, z;
} vect3;
However I found out in other headers such as Win32, that it tends to be like ...
4
votes
7
answers
279
views
How to define API in header and private fields in source in c
I want to define an API function in header file, and then implement it in source file.
Here is the hello.h, I want to define "world" in header:
typedef struct Hello {
int (*world) (void);...
0
votes
0
answers
148
views
How do I create larger structs using tables in lua? (in the pico-8 game engine)
I am making a card game and im now revamping how individual card information is stored.
a single card would have the following values:
x, y, suit, number, state
this is to be stored in a deck array ...
0
votes
6
answers
274
views
Pointer to an array in a struct in C
I'm working (in C) with a struct that contains arrays of strings. How do I point to one of those strings?
To make it a bit clearer, consider:
struct Books {
char title[MAX1][MAX2];
char author[MAX1][...
3
votes
2
answers
170
views
Accessing a struct member from what is not the same struct type
The code below looks crazy, because I am interested in finding out the limits of what’s possible, and it isn’t exactly what I’m doing in my real code. It compiles without warnings and works as ...
0
votes
0
answers
94
views
In C#, is an instance of a struct really an object? [duplicate]
I’ve been working with C# for 4 months. I’ve gained some experience, good and bad. Lately, I wanted to focus more on the concept of objects.
There’s a very important point that has been bothering me. ...
3
votes
1
answer
111
views
Compare structs in Odin
I have the following code in Odin:
Foo :: struct {
x: int,
y: int,
}
a := Foo{1, 1}
b := Foo{1, 1}
#assert(a == b)
According to official documentation I would expect to be able to compare ...
-2
votes
1
answer
62
views
What is the struct operator in SMT-LIB? [closed]
I want to create structures in SMT-LIB, like structs in C. So I coded this:
(set-option :print-success false)
(set-logic HO_ALL)
(declare-datatype |struct(Note : Z, Suffisant : BOOL)| (|record struct(...
-5
votes
2
answers
176
views
How to avoid heap allocation when calling interface methods on multiple struct types in a shared list [closed]
I'm writing a program that is very sensitive to garbage collection so I'm trying to avoid allocating to the heap after initialization.
In the example below, calling Run() will allocate to the heap ...
-2
votes
2
answers
136
views
Facing issues with Structs and malloc in an assignment question [closed]
This was a question in a C Programming assignment given to me as a part of last week's assessment. Requesting everyone to kindly explain what needs to be done and how it needs to be done. Kindly note ...