Skip to main content
Filter by
Sorted by
Tagged with
2 votes
3 answers
465 views

How would one implement a dynamic associative array that could take any number of mixed indices (integers, strings, or both)? I aim to simulate structures by providing, for example, people[3]....
user avatar
16 votes
2 answers
13k views

in this example procedure foobar; var tab:array of integer; begin setlength(tab,10); end; is the array destroyed or the memory is leaking?
Azarien's user avatar
  • 201
0 votes
3 answers
5k views

Is that Destructor is enough or do I have to iterate to delete the new nodes?? #include "stdafx.h" #include<iostream> using namespace std; struct node{ int row; int col; ...
Ahmed Sharara's user avatar
1 vote
2 answers
4k views

I need to create multi-dimensional array of strings. Each row of the array can have varying number of strings. Something like the follwing code: twoDimension = Array(Array()) ReDim Preserve ...
user344811's user avatar
6 votes
4 answers
3k views

I have a large code base, originally C ported to C++ many years ago, that is operating on a number of large arrays of spatial data. These arrays contain structs representing point and triangle ...
SmacL's user avatar
  • 23k
6 votes
4 answers
1k views

In Delphi, it is possible to create an array of the type var Arr: array[2..N] of MyType; which is an array of N - 1 elements indexed from 2 to N. If we instead declare a dynamic array var Arr: ...
Andreas Rejbrand's user avatar
3 votes
2 answers
937 views

Is there a way to access (and call) procedures like _CopyArray that are defined in the interface in the unit System? NB: I am trying to create a routine that makes a deep clone of any dynamic array, ...
Ritsaert Hornstra's user avatar
10 votes
7 answers
14k views

I have a choice. I have a number of already ordered strings that I need to store and access. It looks like I can choose between using: A TStringList A Dynamic Array of strings, and A Linked List of ...
lkessler's user avatar
  • 20.2k
3 votes
3 answers
2k views

Maybe there's no way to solve this the way I'd like it but I don't know everything so I better ask... I've implemented a simple Queue with a dynamic array so the user can initialize with whatever ...
rfgamaral's user avatar
  • 16.9k
0 votes
2 answers
1k views

This program is meant to generate a dynamic array, however it gives an access violation error when writing when given certain dimensions. Eg: R = 6, C = 5 crashes, but then R = 5, C = 6 doesn't. In ...
fauxCoder's user avatar
  • 364
11 votes
4 answers
2k views

I'm relatively new to C++, and from the beginning it's been drilled into me that you can't do something like int x; cin >> x; int array[x]; Instead, you must use dynamic memory. However, I ...
Maulrus's user avatar
  • 1,847
3 votes
4 answers
444 views

I have a class defined as: class Obj { public: int width, height; Obj(int w, int h); } and I need it to contain a static array like so: int presc[width][height]; however, I cannot define ...
user avatar
3 votes
3 answers
4k views

I have a struct with a dynamic array inside of it: struct mystruct { int count; int *arr; } mystruct_t; and I want to pass this struct down a pipe in C and around a ring of processes. When I alter ...
user300521's user avatar
1 vote
4 answers
3k views

I'm a bit confused about handling an array of objects in C++, as I can't seem to find information about how they are passed around (reference or value) and how they are stored in an array. I would ...
David Mason's user avatar
  • 2,967
1 vote
5 answers
3k views

I create a 2D array in C as follows: int **arr; arr = malloc(rows * sizeof(int *)); for (i = 0; i < rows; i++) arr[i] = malloc(cols * sizeof(int)); Now, I call: func(arr) In the function ...
user2698's user avatar
  • 325
5 votes
7 answers
10k views

In my program I have a bunch of growing arrays where a new element is grown one by one to the end of the array. I identified Lists to be a speed bottleneck in a critical part of my program due to ...
Projectile Fish's user avatar
1 vote
4 answers
2k views

I attempted to adapt a class I had found on the web for a dynamic array of ints for a dynamic array of "Entities," but now I am getting a "NullPointerException." The code raising the exception is: ...
Jonathan Chan's user avatar
4 votes
3 answers
630 views

Here's a simple program to check memory allocation. Checking before and after values with Task Manager suggests that each dynamic array takes up 20 bytes of memory at size = 1. The element size is 4,...
Mason Wheeler's user avatar
0 votes
1 answer
428 views

After writing the following program, it does not appear to pass arguments to the called application. While researching _spawnv and what it can do, _execvp was found as what appeared to be a suitable ...
Noctis Skytower's user avatar
1 vote
4 answers
229 views

I have this snippet of code which I am considering to simplfy: if (numberOfResults > 1) { trackResult_ = new TrackResult[numberOfResults]; for (int i=0; i < numberOfResults; i++) ...
Extrakun's user avatar
  • 19.3k
12 votes
1 answer
7k views

Consider the following example: int size = 10, *kk = new int[size]; for (int i = 0; i < size; i++) { kk[i] = i; } delete [] kk; How can I add a watch for the whole array? I can add a watch ...
Keiji's user avatar
  • 245
1 vote
9 answers
3k views

Simple question, I'm writting a program that needs to open huge image files (8kx8k) but I'm a little bit confused on how to initialize the huge arrays to hold the images in c++. I been trying ...
StfnoPad's user avatar
  • 1,027
0 votes
6 answers
3k views

**** Sorry for the confusion regarding numCars in the original post. I modified the code to be consistent with the original ****** The following academic program is a simplified version of the ...
Athens Holloway's user avatar
2 votes
4 answers
2k views

I need to create a structure that holds a variable number of 'char[2]'s, i.e. static arrays of 2 chars. My question is, how do I allocate memory for x number of char[2]. I tried this (assuming int x ...
ejm's user avatar
  • 835
1 vote
4 answers
2k views

So I have this 2d dynamic array which content I want to free when I am done with it. However I keep running into a heap corruption after the destructor. The code works fine (of course with memory ...
Extrakun's user avatar
  • 19.3k
119 votes
12 answers
34k views

C++ has std::vector and Java has ArrayList, and many other languages have their own form of dynamically allocated array. When a dynamic array runs out of space, it gets reallocated into a larger area ...
Joseph Garvin's user avatar
37 votes
2 answers
87k views

I originally had an array[1..1000] that was defined as a global variable. But now I need that to be n, not 1000 and I don't find out n until later. I know what n is before I fill the array up but I ...
Arthur's user avatar
  • 3,478

1
34 35 36 37
38