arrays

Initialize 2-D array of unknown size

I have a 2-D array of characters e.g. char aList[numStrings][maxLength]. ideally, during program execution I want to be able to modify the contents of aList i.e. add, amend or delete entries. Since aList will be subject to change, I don't want to have to recompile my program after every such change to modify aList. So I want to write aL...

Javascript Canvas Element - Array Of Images

I'm just learning JS, trying to do things without jQuery, and I want to make something similar to this however I want to use an array of images instead of just the one. My image array is formed like this var image_array = new Array() image_array[0] = "image1.jpg" image_array[1] = "image2.jpg" And the canvas element is written like t...

Read CSV and create different arrays.

I am creating a script to read values from csv files and use the values for other taskes. I have written the below code to read values. sample file: site,type,2009-01-01,2009-01-02,.... X,A,12,10,... X,B,10,23,... Y,A,20,33,... Y,B,3,12,... and so on.... Code: my @value; while (<INFILE>) { next if $_ !~ /B/; my ($v1, $v...

Visual Basic 6 Empty Array Index

In VB6 it is possible to prepand array identifiers with an empty array index. For example: Dim x(0 To 20) As Integer x(0) = 1 Debug.Print x(0) Debug.Print x()(0) The debug statements appear to the same thing, even though an empty index is given to the array before the index in the last statement. Does anyone know what this is and why ...

Pointers and arrays in Python ctypes

I have a DLL containing a C function with a prototype like this: int c_read_block(uint32 addr, uint32 *buf, uint32 num); I want to call it from Python using ctypes. The function expects a pointer to a chunk of memory, into which it will write the results. I don't know how to construct and pass such a chunk of memory. The ctypes documen...

Initializing arrays in C++

I'm trying to initialize the last element in the array int grades[10]; to grade 7 but it doesn't seem to work I'm using C++ btw ...

Problem with 2D Array of JButton

I need to put number(2d array) on the top left of JButton. But, i got the number result in wrong ordder (upside down), not as the same as the array topLeftNum order. How to make it so the number will show up as the same order?Please help me solve my problem..Thanks final int ROWS = 12; final int COLS = 12; final static int topLeftNum[...

How do I choose the correct view for zooming with multiple UIScrollView objects in a view (iPhoneSDK obj-C)?

I have added several UIScrollViews as subviews of a single UIView and set the frames so that each one is clearly visable. I set scrollEnabled to YES and set the contentSize larger than the bounds/frame. I do this in a for loop, and with each pass of the loop I release the UIScrollView (though the object is still stored because it has bee...

Java: Copy array of non-primitive type

What is the prefered way to copy an array of a non-primitve type in Java? How about performance issues? ...

Dynamic Byte Array in C# by Socket Programming [List<byte> does not work]

Hi to all, I'm sending to a device a request as byte array and I want to receive the anwser device gives. ... Socket deviceSocket = new Socket(server); List<byte> coming = new List<byte>(); ... deviceSocket.Receive(coming) Here the program gives error: Error 1 The best overloaded method match for 'System.Net.Sockets.Socket.Recei...

foreach object/array in jQuery

Hai all i have a problem, i have X <input type="checkbox" /> ind my code, now i what to foreach this object/array its out put. - look my code. $("#denied_seekrs").click(function() { if (!isCheckedById("selectname")) { alert ("Please select at least one event"); return false; } else { ...

how to perform mathematical operations on Array of Arrays?

I have an array of array like below with all numeric values. I want to perform some mathematical operations with these values. 1) Add and print the values of each array elements. e.g. sum $VAR1 = sum1 sum $VAR2 = sum2 2) Add all the values from each variables. e.g. sum $VAR1 + $VAR2 +...+ $VARn = totalsum 3) Finding percentage of ...

How to create a 2D array in C++ using this specific container

I'm trying to port a int a[][] from Java to C++. I'm using this class as a container ArrayRef for ints because it handles references, and the project uses it extensively. In the AbstractReader class I declared const ArrayRef<int> START_END_PATTERN_; const ArrayRef<int> MIDDLE_PATTERN_; const ArrayRef<ArrayRef<int> > L_PATTERNS_; co...

Ruby list of tags to a fluent regex

I want to clean an HTML page of its tags, using Ruby. I have the raw HTML, and would like to define a list of tags, e.g. ['span', 'li', 'div'], and create an array of regular expressions that I could run sequentially, so that I have clean_text = raw.gsub(first_regex,' ').gsub(second_regex,' ')... with two regular expressions per tag (...

Printing an array in C++?

Is there a way of printing arrays in C++? I'm trying to make a function that reverses a user-input array and then prints it out. I tried Googling this problem and it seemed like C++ can't print arrays. That can't be true can it? ...

c++: function arg char** is not the same as char*[]

I am using g++. I am using code that had a main(int,char**), renamed so I can call it. I looked at http://stackoverflow.com/questions/779910/should-i-use-char-argv-or-char-argv-in-c, where char** is said to be equivalent to char* []. This does not appear to be true in c++ function calls. For example: void f1(char** p){;} void f2(ch...

PHP prepend associative array with literal keys?

Is it possible to prepend an associative array with literal key=>value pairs? I know that array_unshift() works with numerical keys, but I'm hoping for something that will work with literal keys. As an example I'd like to do the following: $array1 = array('fruit3'=>'apple', 'fruit4'=>'orange'); $array2 = array('fruit1'=>'cherry', 'frui...

How to check if a PHP array has any value set?

I am working on a signup form, I am using PHP and on my processing part I run some code, if a submitted item fails I then add it to an errors array. Below is a snip of the code, I am at the point where I need to find the best method to determine if I should trigger an error. So if there is a value set in the error array then I need t...

Java (6) Hash & Array alternatives that behave more like their Ruby counterparts

Having been spoiled by ruby for so long, I now find myself having to do some Java development (Eclipse RCP). I'm wondering if anyone knows of alternatives to HashMap & ArrayList that have some of the sugar of ruby. The verbosity of dealing with an ArrayList of HashMaps drives me bonkers. I'm also interested in finding other Ruby langua...

How can I show session array items in PHP

How can I make something like this below work? <?PHP $_SESSION['signup_errors']['test1']; $_SESSION['signup_errors']['test2']; $_SESSION['signup_errors']['test3']; $_SESSION['signup_errors']['test4']; foreach ($_SESSION['signup_errors'] as $key => &$value) { echo $value; } ?> Warning: Invalid argument supplied for foreach() ...