Tag structure

[Solved] Access element of array of pointer of structure

#include <stdio.h> #include <stdlib.h> int main() { struct hash { int pages; int price; }; struct hash *h[2]; h[0] = malloc(sizeof(struct hash)); h[0]->pages = 1; h[0]->price = 2; h[1] = malloc(sizeof(struct hash)); h[1]->pages = 3; h[1]->price = 4; printf(“value =‚Ķ

[Solved] Functions in Structures ? C++

Options() is your default constructor. Structs and classes are equivalent in the sense that they can have methods and constructors. What’s after : is the initialisation list for Options(). It tells you that in your default constructor for Options(): num_particles‚Ķ

[Solved] How can you use structures in modular programming?

Well, this is a problem: fillwordnr(f,p[].ptrletter,p[].numbers,lines,nrofline,a,c,string[]); You have to specify which element of p you want to work with Рp[0], p[1], p[i], etc. Assuming nrofline is a valid index for p, you would write fillwordnr( f, p[nrofline].ptrletter, p[nrofline].numbers, lines,…

[Solved] How to initialize nested structures in C++

You should debug your code by yourself. void stack::push(int *dat) { ch::LinkList* newNode = new ch::LinkList; newNode->initialize(dat,ptr); ptr->head = newNode; } void stack::ch::LinkList::initialize(int *dat, ch *nxt){ data = dat; if(nxt->head) next = nxt->head; else next = 0; } Note that:…