I have a structure and a bidimensional array of those structs:
typedef struct {
char exit_n;
char exit_s;
char exit_w;
char exit_e;
} room;
room map[MAP_WIDTH][MAP_HEIGHT];
I need an array of pointers those structs. The following code compiles, but ... |
The objective is to build a "infinite" tree using dynamic arrays.
items[3]
- MENUITEM
- items[2]
- MENUITEM
-items[0]
- MENUITEM
...
|
I have something like this in my code
typedef struct ts_fem_mesh
{
double **vertices;
unsigned ...
|
curiousEngine how to make provision of a dynamic array say of size 5 with each slot holding a structure of type passenger? /* * Labsheet Queues Question 1 Implement a program that shows a queue of people lining at a bus-stop. The first one in the queue is the first one to get on the bus. Your program should display the ... |
Hi, My question is more of a perfomance or common practice doubt about dynamic structures usage: I have a function that will be called to search a file for a certain condition in particular time windows. This function returns all the time windows that satisfy this condition. The amount of time windows that satisfy the condition will rarely be high (suppose ... |
I have a problem regarding array of structures within a structure. I have an static array of structure within a structure eg. typedef struct { int x; }A; typedef struct { int no_of_a; A a[5]; int y; int z; }B; Where no_of_a gives the number of values of structure A I have to store in B Now my problem is that ... |
Hi everyone! So what is I'm supposed to do, is kind of a index program, which works, for example, like that: ./a.out FILE word1 word2 word3... it should show: word1 accused in lines 1 2 3 word 2 acussed in lines 4, 5, 6 etc.. but I've got some problem with structures that keeps informations about words; heres the part of ... |
|
dynamic array and structure problem Hi all, I have been trying to make a program to test pointers and structures amongst other things. I have tried to reduce it to the minimal expression because this is where the problem is. The code consists on a structure, three functions (one of which is just a menu). The two important functions are employee ... |
Hi, I'm a novice when it comes to programming. Right now I'm in college taking my first class on C++, but our first homework assignment is in C. Anyways, the first programming assignment is fairly large and I've been working on it for a few days now. However, there's a certain part of the program where I'd love to utilize structures ... |
Hi all I have been given the task of using malloc to allocate space dynamically for a structure of arrays, that must have the integer elements execution_time and process_number and a float element called average_time. Set up an array of structures and show how to access individual elements of the structures within the array. Then finally, use malloc to allocate space ... |
Dynamic array of structures containing yet another dynamic array of structures Hello, I want to create an array of structures wherein the array is dynamic. Inside the parent structure, there is another array of structures which is also dynamic. I am not able to resolve some issues while trying to compile it...Kindly help me out. Firstly, i have the code below ... |
I don't know if the title was the best choice but I dunno what else to write there... Here's my problem: I have the following structures: Code: struct example1 { int size; int items[20]; } struct example2 { int size; int items[100]; } Both items array on both the structures will have only numbers between 1 and 50 (for instance), if ... |
Hi, I know this is late, but it's on this same topic. Your assistance so far has been really great. I'm stuck on validating the "location-to-insert" in the list. Here's what I have: Code: //insert_database: insert ctry into the right element of db list void insert_database( struct Database * db, struct Country * ctry ) { int i, insertAt = 0; ... |
|
Of course, you are not providing the actual error message, so we are guessing a bit, but kudos for using code tags. You are declaring pa twice, once as a zero length array and again as a pointer. You should have been getting some sort of error in that regard. If you want a list of objects that grows dynamically you ... |
Hi all, I have an assignment for class, where the instructor wants us to use some two-dimensional array's in a program to solve quadratic equations. Basically, we are supposed to create a program where the user executes it, and passes in via the command line the number of equations to solve. Then we are supposed to read in the three coefficients ... |
#include #include #include #define MAX 128 typedef char String[MAX]; typedef struct { String name; float s; } ST; int main() { int size; ST *p; p= (ST *) Malloc (1*sizeof(ST)); size=-1; printf("Enter name (\"exit\" to exit"); printf("What is the name :"); scanf("%s",(*p).name); printf("Enter size:\n"); scanf("%f",&(*p).s); while(strcmp((*p).name,"exit")!=1) { size++; p[size].name= (*p).name; p[size].s= (*p).s; p=(ST *)realloc(ST,1*sizeof(ST)); printf("What is the name ... |
I dunno, there are std::strings in that struct, it probably would work to realloc them, but it might depend on the implementation, so I'd say it's not guaranteed to work with realloc. I know I do keep running into errors where colleagues in an effort to 'objectize' our legacy application replace char* attributes with std::string but forget to replace the memset() ... |
I have a structure in a C program defined:struct { char *Name; char *Mod_Image; char *ICA_Image; int ... |