I need to declare an array of pointers to functions like so:
extern void function1(void);
extern void function2(void);
...
void (*MESSAGE_HANDLERS[])(void) = {
function1,
function2,
...
};
However, I want the the array to be declared as constant -- both the data in the array and the pointer to the data. Unfortunately, I do n...
I am trying to create an array starting with today and going back the last 30 days with PHP and I am having trouble. I can estimate but I don’t know a good way of doing it and taking into account the number of days in the previous month etc. Does anyone have a good solution? I can’t get close but I need to make sure it is 100% accurate...
I went looking for this the other day, and thought it should probably be added to StackOverflow's reservoir of questions.
How would I go about dynamically allocating a multi-dimensional array?
...
I'm trying to create a function which takes an array as an argument, adds values to it (increasing its size if necessary) and returns the count of items.
So far I have:
int main(int argc, char** argv) {
int mSize = 10;
ent a[mSize];
int n;
n = addValues(a,mSize);
for(i=0;i<n;i++) {
//Print values from a
}...
I recently ran up against a wall doing some bash shell programming where an associative array would have solved my problems. I googled about features of the Korn shell and learned that it supports associative arrays, so I installed Cygwin's pdksh (public domain korn shell).
However, when trying to create an associative array in the pre...
var myArray = new Object();
myArray["firstname"] = "Bob";
myArray["lastname"] = "Smith";
myArray["age"] = 25;
Now if I wanted to remove "lastname"?....is there some equivalent of myArray["lastname"].remove()?
(I need the element gone because the number of elements is important and I want to keep things clean).
Thanks in advance to eve...
I currently am trying to write a python program using scheme semantics so I can later translate it into scheme without relying on a lot of pythonic stuff.
I'm trying solve the sliding puzzle problem (where you have 9 slots and 8 tiles arranged in a square) using a*, depth first, and breadth first search algorithm. I did this ~11 years ...
When you have an array like this:
int foo[3][2][2];
and you make:
int *bar = &foo[0][0][0];
Is this the way it works?
*bar == foo[0][0][0];
*(bar+1) == foo[0][0][1];
*(bar+2) == foo[0][1][0];
*(bar+3) == foo[0][1][1];
*(bar+4) == foo[1][0][0];
I'm not sure and have a bit of code dependent on if that works.
...
I made an array in PHP which holds a bucnh of unix timestamps.
I'm trying to make a function that will return an array containing the indexes of the 3 largest numbers in that array.
For instance, if the largest numbers are located at indexes 3,5 and 8
And if the largest is 5, second largest is 8 and smallest of the three is number 3, ...
By means of a regular expression and Greasemonkey I have an array of results that looks like:
choice1, choice2, choice3, choice3, choice1, etc..
My question is how do I tally up the choices so I know how many times choice1 is in the array, choice2 is in the array, etc. if I do not know exactly how many choices there are or what they...
Is it possible in PHP to do something like this? How would you go about writing a function? Here is an example. The order is the most important thing.
$customer['address'] = '123 fake st';
$customer['name'] = 'Tim';
$customer['dob'] = '12/08/1986';
$customer['dontSortMe'] = 'this value doesnt need to be sorted';
And I'd like to do som...
I want to create an array with a message.
$myArray = array('my message');
But using this code, myArray will get overwritten if it already existed.
If I use array_push, it has to already exist.
$myArray = array(); // <-- has to be declared first.
array_push($myArray, 'my message');
Otherwise, it will bink.
Is there a way to make...
The following is a simplified version of what I'm trying to do, because I'm sure you don't want to wade through an entire set of structs and function prototypes for a particle system.
float const materials[24][4][4] = {{{...}}};
typedef struct EmitterStruct { float *material[4][4]; } Emitter;
typedef struct ParticleStruct { float mater...
Hello,
as I am implementing the ICollection-Interface in my class I want to implement the CopyTo-Method and I have to throw an Argument-exception if the array is multidimensional.
What is meant by this? The head of my method is this
public void CopyTo(MyClass[] array, int arrayIndex)
I thought these brackets would mean that the given...
I have two arrays in PHP. The first array ($author_array) is comprised of user_ids in a particular order, like so: (8, 1, 6)
The second array ($user_results) is comprised of an array of objects like so:
Array
(
[0] => stdClass Object
(
[ID] => 1
[user_login] => user1
)
[1] => stdClass Obj...
What is the meaning, and where is the Ruby documentation for the syntax of:
Array(phrases)
which I found browsing the Rails source here:
# File actionpack/lib/action_view/helpers/text_helper.rb, line 109
...
119: match = Array(phrases).map { |p| Regexp.escape(p) }.join('|')
I thought that Array.new would normally be used...
I'm trying to run a 3d array but the code just crashes in windows when i run it, here's my code;
#include <iostream>
using namespace std;
int main(){
int myArray[10][10][10];
for (int i = 0; i <= 9; ++i){
for (int t = 0; t <=9; ++t){
for (int x = 0; x <= 9; ++t){
myArray[i][t][x] = i+t...
Hi guys,
I tried to make a dynamic 2D array of char as follow:
char** ppMapData = (char**)malloc(sizeof(char*)*iMapHeight);
for (int i=0; i< iMapHeight; i++)
{
ppMapData[i] = (char*)malloc(sizeof(char)*iMapWidth);
//do something
}
// do something
for (int i=0; i<iMapHeight; i++)
free(ppMapData[i]);
free(ppMapData);
It lo...
So in C#, I can treat a string[] as an IEnumerable<string>.
Is there a Java equivalent?
...
This code throws up the compile error given in the title, can anyone tell me what to change?
#include <iostream>
using namespace std;
int main(){
int myArray[10][10][10];
for (int i = 0; i <= 9; ++i){
for (int t = 0; t <=9; ++t){
for (int x = 0; x <= 9; ++x){
for (int y = 0; y <= ...