arrays

Homework: In C, how does one get a substring of an array using only pointers?

Using pointer arithmetic, it's possible to assign characters from one array to another. My question is, how does one do it given arbitrary start and stop points? int main(void) { char string1[] = "something"; //[s][o][m][e][t][h][i][n][g][\0] int start = 2, count = 3; char string2[10] = {0}; char *ptr1 = &string1[start];...

how to get my while loop to work?

Hi, I have a programme in which I have written three functions, difference (that calculates the difference in numbers between arrays) sum (that totals the array up) and calculate difference which uses the difference function to determine what the next array should be). All these functions are working but I'm having problems getting the...

How can I make a Perl hash from an array with the keys and another array with the values?

In Perl, how do I make hash from arrays @A and @B having equal number of elements? The goal is to have each value of @A as key to value in @B. The resulting hash %C would,then make it possible to uniquely identify an element from @B supplying key from @A. ...

How do you retrieve the array adapter currently set for a spinner? Android OS, Droid

Looking to create a menu toggle that switches between two possible arrays for a spinner. For example, if the spinner is set to show array A, then when I press this menu button, I want the spinner to be set to array B. If I press it again, I want it to be set back to array A. I can handle the if/then statements and all, but how do I call...

array of loaders?

How does one create an array of loaders? The bigger picture: I have written a mapping program in flex. I want to change my mapping program so that all I need to do is drop in a new xml file instead of going into my flex file and adding the exact number of item loaders I need. So I guess I'm looking for an array of loaders that can load...

Mixing arrays and objects

I feel bad about mixing arrays with objects, but I'm not sure that I should. // Populate array foreach($participants as $participant){ $participants[$key]['contestant'] = new Contestant($participant); $participants[$key]['brand'] = new Brand($brand); $key++; } [...] // Print array foreach($participants as $participant){ pr...

Fastest / most efficient way to compare two string arrays Javascript

Hi I was wondering whether anyone could offer some advice on the fastest / most efficient way to compre two arrays of strings in javascript. I am developing a kind of tag cloud type thing based on a users input - the input being in the form a written piece of text such as a blog article or the likes. I therefore have an array that I ke...

How to insure column match for MySQL insert, when number and names of input fields will vary?

Hello! Working on a pre-existing program that parses an html form that has a dynamically created number of fields, and in the interest of forward-compatibility, may not even know number of mysql columns... I imagine that this requires creating two arrays, and comparing/re-ordering of some sort, but can't quite wrap my head around it......

Convert a String Containing an Array to an Array in Ruby

I have a string that contains an array that i would like to convert into an array. How would you do this? I want to convert this: myvar= "[[Date.UTC(2010, 0, 23),0],[Date.UTC(2010, 0, 24),0],[Date.UTC(2010, 0, 25),3],[Date.UTC(2010, 0, 26),0],[Date.UTC(2010, 0, 27),0],[Date.UTC(2010, 0, 28),0],[Date.UTC(2010, 0, 29),0],[Date.UTC(2010,...

Passing pointer to 2D array c++

I'm having this problem for quite a long time - I have fixed sized 2D array as a class member. class myClass { public: void getpointeM(...??????...); double * retpointM(); private: double M[3][3]; }; int main() { myClass moo; double *A[3][3]; moo.getpointM( A ); ??? A = moo.retpointM(); ??? ...

Inserting string array value in for loop in java

Hi folks, I know this is a very simple thing, but I can't see any examples of doing this with strings. This is beyond the basic exercise in my self imposed homework, and more advanced, but I know it can be done so I just want to go ahead and learn these arrays :-D I'm trying to change the value if the string in the GLabel below: priva...

Returning arrays

main() { .... i = index; while (i < j) { if (ip[i] == "/") { ip[i - 1] = (double.Parse(ip[i - 1]) / double.Parse(ip[i + 1])).ToString(); for (int k = i; k < (ip.Length - 2); k++) { ip[k] = ip[k + 2]; } Array.Resize(ref i...

Return an array from mysqli stmt query

Hi there i'm trying to convert a site to use prepared mysql statements, however i'm having some trouble replacing my use of fetch_array(). The comments on php.net offer a solution which I would have thought should work but for some reason i'm getting strange undefined constant errors when calling a function via call_user_func_array() ca...

how to format mysql results to json php

hello mysql table ID >> Name >> Salary $row_set << database table information. my problem is when i use json_encode($row_set); the output will be something like this: [{"0":"1","ID":"1","1":"x","Name":"x","2":"12345","Salary":"12345"}] i want the results to be something like this [{"ID":"1","Name":"x","Salary":"12345"}] ho...

Array Foreach Loop

Hi All, I'm running a RegEx to match all instances of the Twitter hashtag. It returns it just fine, but now I just want to loop through the first set and return my #hello, #world, #hello-world....not the second set. Any help will be quickly rewarded! Array ( [0] => Array ( [0] => #hello [1] => #wor...

C++ class for arrays with arbitrary indices

Do any of the popular C++ libraries have a class (or classes) that allow the developer to use arrays with arbitrary indices without sacrificing speed ? To give this question more concrete form, I would like the possibility to write code similar to the below: //An array with indices in [-5,6) ArbitraryIndicesArray<int> a = ArbitraryIndi...

ANSI-C grammar - array declarations like [*] et alii

The ANSI C grammar from -link- give me the following rules for array declarations: (1) | direct_declarator '[' type_qualifier_list assignment_expression ']' (2) | direct_declarator '[' type_qualifier_list ']' (3) | direct_declarator '[' assignment_expression ']' (4) | direct_declarator '[' STATIC type_qualifier_list assignment_expre...

Compare/Difference of two arrays in bash

Hello, Is it possible to take the difference of two arrays in bash.. Would be really great if you could suggest me the way to do it.. Code : Array1=( "key1" "key2" "key3" "key4" "key5" "key6" "key7" "key8" "key9" "key10" ) Array2=( "key1" "key2" "key3" "key4" "key5" "key6" ) Array3 =diff(Array1, Array2) Array3 ideally should be : Ar...

Which PHP interface allows objects' properties to be accessible with array notation?

Which PHP SPL interface allows objects to do this: $object->month = 'january'; echo $object['month']; // january $record['day'] = 'saturday'; echo $record->day; // saturday e.g. such as in libraries like Doctrine (Doctrine_Record) how do I implement this? I've tried using ArrayObject, but they don't behave as I thought they would. ...

How can I get the number of instances of a value in a Rails array?

Say I have an array like this: ["white", "red", "blue", "red", "white", "green", "red", "blue", "white", "orange"] I want to go through the array and create a new array containing each individual color and the amount of times it appeared in the original array. So, in the new array it would report that "white" appeared 3 times, "blu...