arrays

C - Pass by reference multidimensional array with known size

In main: char *myData[500][9]; //dynamic rows?? char **tableData[500]={NULL}; //dynamic rows?? int r; newCallBack(db, &myData, &tableData, &r); and passing into function by: void newCallBack(sqlite3 *db, char** mdat, char*** tdat, int* r ) { Doesn't seem to like this? Any suggestions? Lots of examples online when you don...

How do I make a pointer to a multidimensional array which has an unknown size?

how do I make a pointer to a multidimensional array, which have a unknown size? I've tried this: int **triangles; triangles = new int[numTriangles][3]; But i get this error: cannot convert 'int (*)[3]' to 'int**' in assignment ...

C++ Passing a dynamicly allocated 2D array by reference

This question builds off of a previously asked question: Pass by reference multidimensional array with known size I have been trying to figure out how to get my functions to play nicely with 2d array references. A simplified version of my code is: unsigned int ** initialize_BMP_array(int height, int width) { unsigned in...

Memory management - should I worry about resizing a temporary array of long-lived objects within a state machine?

Garbage collection in .NET leads many to believe that lightweight objects can be treated as temporary. This seems especially true of arrays that hold object references to objects that are instantiated outside of the context of the array initialization. Consequently, it would seem that it should not really matter if a new array is in...

Web service array size limit

My web method kept faulting and investigations eventually revealed the following: The formatter threw an exception while trying to deserialize the message: Error in deserializing body of request message for operation 'SendFirmware'. The maximum array length quota (16384) has been exceeded while reading XML data. This quot...

dim ASP Array

I want to define an array. My question is Dim x(999) or Dim x(9999) will cost the same or Dim x(9999) will waste more resource? Thank you very much!! ...

What is the difference between Dim v As String() and Dim v() As String?

This may sound trivial, but what is the difference between Dim v As String() and Dim v() As String in VB.NET? ...

How to get rid of . and .. while scaning the folder creating an array in php?

If you scan a folder containing other folders AND files, how do you get rid of . and .. and files? How do you put in array only folders WITHOUT . and ..? I would like to use regular expression, but I'm newbie and I can't get it right. My code is now this but doesn't work: if(fnmatch("\.{1,2}",$dir_array[$i]) || is_file($dir_array[$i]...

Simple C code, with vexing "incompatible types in assignment" error

Just a simple program to get used to pointers. The program is supposed to put the contents of a portion of my memory into a character array in reverse order of how the memory is read. I.E. looking at descending memory address, and I want to store it in descending order in a character array. My compiler keeps telling me: "error incompa...

XML Deserialization and Loose Array Items

So I'm working with some XML files that I believe are most likely badly formed, and I'm trying to figure out how and if I can use the XmlSerializer to deserialize this XML into a logical business object. Let's say I have the following XML file: <Root> <ArrayType1 Name="Bob"/> <ArrayType1 Name="Jim"/> <ArrayType2 Name="Frank"> ...

Search and replace multiple values with multiple/different values in PHP5?

Is there an inbuilt PHP function to replace multiple values inside a string with an array that dictates exactly what is replaced with what? For example: $searchreplace_array = Array('blah' => 'bleh', 'blarh' => 'blerh'); $string = 'blah blarh bleh bleh blarh'; And the resulting would be: 'bleh blerh bleh bleh blerh'. ...

How do you make sense of the error: cannot convert from 'int []' to 'int []'

When compiling the following code: void DoSomething(int Numbers[]) { int SomeArray[] = Numbers; } the VS2005 compiler complains with the error C2440: 'initializing' : cannot convert from 'int []' to 'int []' I understand that really it's trying to cast a pointer to an array which is not going to work. But how do you explain the ...

Using two(multi) dimensional array in Erlang

These days I'm solving Project Euler problems in Erlang. Since I'm a C++ programmer from the beginning, sometimes I really want to code using two dimensional arrays. One of my idea is to use tuples and lists like this: List=[{X,0}||X<-lists:seq(1,3)] {1,0} {2,0} {3,0} Is there nice way to implement multidimensional arrays in Erlang,...

Reserve memory for list in Python?

When programming in Python, is it possible to reserve memory for a list that will be populated with a known number of items, so that the list will not be reallocated several times while building it? I've looked through the docs for a Python list type, and have not found anything that seems to do this. However, this type of list buildin...

Searching for the beginning of a string in an array in C#

I have a List containing a lot of paths. I have a specific path I want to check against this list to see if there are any paths there that uses this path, ie: f.StartsWith(r.FILENAME) && f != r.FILENAME What would be the fastest way of doing this? edit: Complete function from answer below: static bool ContainsFragment(string[] pat...

PHP Array extracting object

Suppose I have an array of a objects of user defined class. Wanted to know how do I extract the elements of the array in PHP. // class definition class User { public $fname; public $lname; } // array of objects of the class defined above $objUser1 = new User(): $objUser2 = new User(): $objUser3 = new User(): $objUser4 = new User(): $a...

How can I distinguish $_ in nested list operators in Perl?

It is often useful to implement algorithms using nested array operations. For example, to find the number of words in a list that start with each given character, you might do something like this in Python: >>> a = ["foo","bar","baz"] >>> map(lambda c: len(filter(lambda w: w.startswith(c), a)), ('a','b','c','d','e','f')) [0, 2, 0, 0, 0,...

Assigning nested movieclips to a multi-dimensional array in flash as2

I have 5 movieclips called row1, row2, ..., row5. Inside each row are the movieclips let1, let2, ..., let15. I want to assign all of the letter clips to a 2 dimensional array. This is a followup to an earlier question http://stackoverflow.com/questions/538133/dynamically-accessing-nested-movie-clips-in-flash-actionscript-2 . I am t...

VB Type Mismatch issues - inArray()

...

How would you query an array of 1's and 0's chars from a database?

Say you had a long array of chars that are either 1 or 0, kind of like a bitvector, but on a database column. How would you query to know what values are set/no set? Say you need to know if the char 500 and char 1500 are "true" or not. ...