Struct Questions
Ad
Getting different header size by changing window size
I have a c++ program representing a tcp header as a struct: #include "stdafx.h" /* tcp header 0 1
C programming: Using structures and functions to determine the number of days between two dates
I have made the corrections suggested by craig estey. the code now compiles and work. this is the revised code: /* programme to
Binary compatibility of struct in separately compiled code
Given a cpu architecture, is the exact binary form of a struct determined exactly? for example, struct stat64 is used by glibc
How to Concatenate Multiple Structs within One Block of Memory?
I'm writing in a program in standard c. i have a number of defined structs, all of different sizes: typedef struct
C: sizeof struct of structs to find number of elements in struct
I have two structs: struct point { double x; double y; const char *description; }; struct geomap { struct point points[];
What does the name of the struct timespec from the C standard library stand for?
As in the title, what does the name of the timespec struct in time.h from the c standard library stand for? is it
Dynamically allocate an object, will the members that aren't ptrs (not dynamically allocated) in the struct be in the stack instead of the heap?
Say i have this struct: typedef struct list_object list; struct list_object { char* name; struct stat stats; };
What are some best practices for searching a binary tree?
I'm learning about binary trees in c and i wrote a function to search my tree which is a tree of strings. it works, however, it seg faults if the
How do I make a pointer inside a struct point to the same string pointed by another pointer?
I have the following code: struct el{ char *line; struct el *next; };
Lifetime of a structure with no arrays in it
Take this code: #include <stdio.h> struct s { int x; int y; }; struct s foo(int a, int b) { struct s s = { a, b };
Ad
Changing global c variable inside a struct array
I have a case where i have defined a global struct array in a seperate header file that i want to be able to change from function in another file
Time compleity of dynamic arrays in C
When we consider dynamic arrays in java or python (list), the average time complexity is o(1) for appending an element and worst
How to dynamically increase size of any structure objects during runtime?
I am a bit of a beginner in c language. i was trying out a task of dynamically reallocating memory as the input comes through(although for this
Reading from a CSV file and separating the fields to store in a struct in C
I am trying to read from a csv file and store each field to a variable inside a struct. i am using fgets and strtok to separate each field.
Why is the address of pointer s the same as when we are accessing the first element of unnamed array?
If string is basically a pointer then how does it behave as an array? ie: you can use say: char *s = "david"
How the struct and pointer acts
While going through a quiz in sololearn app, i came across a certain code. #include <stdio.h> struct node{ int a, b, c;
Accessing a pointer to a struct results in a memory read violation
Recently i've been programming a lot in c, due to an influx of free time. as c (in my opinion) is a very difficult language to pick up and learn,
Declaring pointer to NULL
When i declare: struct str_node{ int data; struct str_node *next; }node; node *head = null; is it
Insertion Sort for Singly Linked List in C
I'm trying to improve my knowledge on algorithms and data structures, so for the last 5-6 days i've been trying to implement different algorithms
Struct Extension in C
Suppose there are 2 structures defined ad such: typedef struct { t x; t y; } a; typedef struct { a a; t z; } b;
Ad
How to set value of struct indirectly in c?
I would like to know, how to access first member of struct through pointer. i have tried this: #include <stdio.h> #include
If struct type is defined in another .c file, it becomes incomplete type?
I can have no problem with this code: #include <stdio.h> struct foo { void * data; }; int main() {
Search key in binary tree
The problem that i have is that for certain keys my function works, but for some it doesn't. the function should return a pointer to the node with
Ask data from user and store them inside a struct in C
In the code below i tried to use printf and scanf to get data from user and store them inside a struct i defined called node. the programme
Incompatible types error from pointer to pointer
Void remove_element(struct node *list) { struct node *temp = list; printf("enter the element value you want to
Value doesn't assign to struct(Pointers)
When i try assign value to *temp, it doesn't assign the value (when i'm compiling, it doesn't show the printf and by printf can't see
How do i pass an array of structs by reference to a function?
I need to write a function that would reflect an image by having ever pixel in the image with in a 2d array of structs. below is the function i
initializing a 2 dimensional array of struct to zero (set the image to all black) in C
I want to pass an image file to a function and make it all black. here is how i do it: typedef struct { byte rgbtblue;
Segmentation fault in C for Stack implementation using arrays with pointers
I have this code for stack implementation using arrays with pointers which performs lot of operations like push, peep, pop, destroy. i already
valgrind Invalid write of size 8 in a allocated memory
I am trying to add new node to my linked list, but it's gives memory error my struct and global vars: typedef struct word
passing a struct to a function doesnt work
In the below code i have create a function apart from main to divided the int inside a struct into half. after that, i want to print out
Ad
Selecting best data structure for a 2-dimensional map that will shift the data
I need some help in the ways of implementing a faster way to do a full shift on a two-dimensional array. my problem is i have a 2
Compiler contribution in assigning garbage values in c
Can we say that when garbage values are assigned to variables in c, they are related to the programs that are executed on the compiler previously
Not displaying all data in C using struct
So i have this simple program in c that i am working on to help me understand structures. there is nothing too complicated about it. however when
Lexical analyzer (Flex) throws lexical error after space following by tokens (and more)
As i run the lexical analyzer with the following example, it seems like it cannot recognize empty space between tokens, and tokens generated with
Return initialisation of struct with union
I'm trying to return a structure with the initialisation list syntax. my structure is a bigger version of this: typedef enum
How do I return a struct with dynamic multidimensional arrays in C?
I have the following problem: "if i try to return a struct with a dynamic multidimensional array, i lose the data inside of that array. if i
How give value to structures in c?
I'm working with structures in c, but i can not give value to the structures' attributes.
C program for salary increment calculation using structure
I would like to write a code for a c program that will: create a structure that will store the employee details. insert 5
Dynamic allocation in struct
#include <stdio.h> #include <stdlib.h> #include <string.h> #define initial_capacity 2 struct student { char
How to change an integer inside a file without coping the file to another
I'm making a program for school where i have to create a function for making exams and another one to get the exam. i did the part to create the
typedef array vs. typedef pointer
Gmp declares the following structure:
Ad
How to handle char * from packed struct in cgo?
Since go doesn’t support packed struct i found this great article explains everything with examples how to work with packed struct in go.
How to init a structure array in C?
I'm coding on a development board with an arm processor, so i use iar workbench as ide. i wonder why compiler gives me an error when training to
can I use struct member from another struct?
From these question: casting one struct pointer to
How many duplicate numbers repeat in array
I want to count how many time duplicate numbers repeat in list. i have written the code that only find the duplicate numbers in list but my
Destructured object as function parameter
I don’t understand the parameter of const posts below. i’m fairly new to node/react. is it a destructured parameter object? or is
trying to name items in a structure using a for loop
For part of my program i need to make items in a structure. however the ammount of items created depends on an input i am trying to give
array type 'char [30]' is not assignable
I have some struct called 'list' which contains id, salary, name of worker and pointer to next node of list. there the code:
How can I define a pointer to variable length array (VLA) in a struct (or equivalent)?
I declared many pointers to variable length array (vla) in a function to allocate 2-d arrays dynamically; for example, int m, n; //
Partial destructuring of object in function arguments in JavaScript
Is there a way to destructure only some object properties in function arguments, while the rest would remain accessible in the object?
Editing structure instance's member values inside single/multiple thread(s)
I am attempting to edit a structure's member value(s) within single/multiple threads on windows, consider the following example:
Can I go back and forth in a list just with pointer algebra and remove prev/next pointers?
So let's say i have a list node like this: struct node{ data_t data; struct node* prev; struct node* next; };
Ad
Null Pointer Error with pre-allocated memory?
While doing a coding exercise in c, i had to allocate memory for a pointer to a structure (cur), even though the structure presumably
Using a pointer to modify a struct
I have two functions: one is a system call: asmlinkage long sys_memstats(struct meminfo __user *info){
Passing an array from a struct as an argument to a function
#include <cs50.h> #include <stdio.h> #include <string.h> #include <stdlib.h> typedef struct { int votes; }
Looking for ideas on a computer science course project
Hey. i'm taking a course titled principles of programming languages, and i need to decide on a project to do this summer. here is a short version
One or Two Primary Keys in Many-to-Many Table?
I have the following tables in my database that have a many-to-many relationship, which is expressed by a connecting table that has foreign keys
How do you represent music in a data structure?
How would you model a simple musical score for a single instrument written in regular standard notation? certainly there are plenty of libraries
Segmentation Fault error - binary search tree in C
I'm trying to build a binary search tree. inserting an integer using insert function (only using 1 to 100 for testing) and appending the result to
Why am i getting errors when changing a file from .c to .h?
I'm trying to make a header file for use in a program that plots vectors to a coordinate system and the problematic part of the code looks like
Error: request for member 'time_c' in something not a structure or union in C language
I have a problem with some of my functions. i want to get a member ob a struct, out of another struct. the normal call is functionel, but embedded
Create a tree from a file .txt in C
My problem is the following: i have to create a tree from a file .txt, this is an example of what is inside the file:
How "struct" members are indexed? How to access them correctly in C?
How the "candidate" stuct is indexed in the following code? when i try to print the last member(last index?) of the created
Ad
why can't you initialize values of structs outside of main() in c?
I get an error in visual studio with the code: struct coordinates { int x; int y; }; struct coordinates point; point.x = 5;
Malformed C/C++ Multidimensional Array Initialization in GCC
I think i get how padding works with a proper format, i.e. this: char arr[3][2] = {{1}, {4,5}}; is equivalent to
Will the size of bitfield be saved even if assigment is via pointer?
Let's assume i have struct foo { unsigned int bar : 7; unsigned int next_field : 1; } void
C error: expected declaration specifiers or '...' before '*' token
So i'm learning data structures and pretty much new to c. i am trying to make a function that accepts student id and the course number and the
Why isn't my Struct char member being assigned the value 'F' and instead is staying the default initialization value?
I am reading in binary data from a disk image and when buffer[0] is equal to 3, the rootdirectory[j] should have its status member be 'f'. however
Hash Functions and Tables of size of the form 2^p
While calculating the hash table bucket index from the hash code of a key, why do we avoid use of remainder after division (modulo) when the size
Double pointer to struct
I have seen this program on the intel website, but i don't understand some lines. if you couldn't understand the program i appreciate it if you
Able to access struct member through character in c?
Basically i have a struct with several members, named a-z. i have a string where i want each letter to correspond to the correct struct member.
How can I find the error in this C program?
I am learning data structures and pretty much new to c. i can't figure out what's causing the error in this function: struct
How should I pass an array of strings to a C library using P/Invoke?
I'm trying to p/invoke from a c# application into a c library, sending over a struct that contains an array of strings. i do have control over the
How to transpile python Compare ast nodes to c?
Let's start by considering python3.8.5's grammar, in
Ad
How can I get a list of the differences between two JavaScript object graphs?
I want to be able to get a list of all differences between two javascript object graphs, with the property names and values where the deltas
Is not catching an exception undefined behavior?
Consider the following code: #include <iostream> class widget { public: ~widget() { std::cout <<
Best way to retrieve K largest elements from large unsorted arrays?
I recently had a coding test during an interview. i was told: there is a large unsorted array of one million
Graph visualization library in JavaScript
I have a data structure that represents a directed graph, and i want to render that dynamically on an html page. these graphs will usually be
Would syntax for composition be a useful addition to Java?
First off, i know next to nothing about language theory, and i barely know any other languages except java, but i had an idea that i think would
Why are entries in addition order in a .Net Dictionary?
I just saw this behaviour and i'm a bit surprised by it... if i add 3 or 4 elements to a dictionary, and then do a "for each" to get all
Building effective external DSLs
What tools are there for me to build a real, honest to goodness external dsl. and no, i'm not talking about abusing ruby, boo, xml or another
Array data structure in nodejs
I'm working on a nodejs project where i need to restructure an array of objects. below is the sample out put i get from database,
How to save a public html page with all media and preserve structure
Looking for a linux application (or firefox extension) that will allow me to scrape an html mockup and keep the page's
C++ Storing constant varibale names within a vector
My task is to write a preprocessor that replaces the constant variable with its actual value. to do this, i have created a struct and a vector to
Save file to struct
I need to read file and save it to struct. example of file input: aaaaa aaaaa 2010 999.00 999.00 999.00 999.00 999.00 bbbbb
Ad
Can't fill dynamic array
I'm learning c++ now and i have some misunderstandings i've created 2d dynamic array, but i can't fill it i've got error in 44 line like: access
How to access sub-struct variables in Racket (Lisp/Scheme)
I'm trying to write an am/pm clock conversion function to a 24 hour clock (military time), but there's a struct and sub-struct that have variables
Why is user defined copy constructor calling base constructor while default copy constructor doesn't?
Consider the following example: class a { public: a() { cout<<"constructor a called:
Solving demanding structure task
The structure is given: struct date { int day, month, year; }; struct subject { int id; char name_of_subject[100]; double
Using "typedef" or "using" to define a structure - which is best?
Sample structure: typedef struct tagexportsettings { colorref crheading{}; colorref crevenback{}; colorref
Accept array from struct array
I need to print all students which average grade is bigger or equal to given average. #include <stdio.h> struct student {
Find the most common elements in array of objects
[{ country: "us", languages: [ "en" ] }, { country: "be", languages: [
Error while modifying mallocated string in a C struct with asm function
I would like to modify a string inside a c structure with an asm function but it is not working properly... let say that i have this type
What are the rules for calling the base class constructor?
What are the c++ rules for calling the base class constructor from a derived class? for example, i know in java, you must do it as the
Register allocation rules in code generated by major C/C++ compilers
I remember some rules from a time ago (pre-32bit intel processors), when was quite frequent (at least for me) having to analyze the assembly
I am getting empty array when I try to upload multiple images to my backend
I have created an api in the backend which will store images to the database, i created a function for uploading the images but i get an empty
Ad
How to Use Typedef Structure Name with Pointer
I am trying to implement a linked list using the given structure for a bigger project. the structure is defined below: typedef
Segmentation Fault In Linked List Append
I have been using linked list and i have used the following code for append function which i wrote in a new file and it works perfectly but when i
Ad
Blog Categories
Ad