28
votes
10answers
8k views

Sizeof an array in the C programming language?

why isn't the size of an array sent as a parameter the same as within main? #include <stdio.h> void PrintSize(int p_someArray[10]); int main () { int myArray[10]; printf("%d\n", ...
11
votes
22answers
3k views

PHP syntax for dereferencing function result [duplicate]

EDIT (Jul 17, 2013): This question was incorrectly voted a duplicate of PHP: Access Array Value on the Fly. This question is not a duplicate, because: the other question does not relate to the ...
10
votes
2answers
3k views

Recursive function to generate multidimensional array from database result

I'm looking to write a function that takes an array of pages/categories (from a flat database result) and generates an array of nested page/category items based on the parent ids. I would like to do ...
20
votes
7answers
59k views

c++ return array in a function

I have an array int arr[5] that is passed to a function fillarr(int arr[]): int fillarr(int arr[]) { for(...); return arr; } How can I return that array? How will I use it, say I returned ...
2
votes
7answers
2k views

C sizeof a passed array [duplicate]

Possible Duplicate: How to find the sizeof( a pointer pointing to an array ) I understand that the sizeof operator is evaluated and replaced with a constant at compile time. Given that, ...
19
votes
9answers
5k views

Why doesn't C++ support functions returning arrays?

Some languages enable you to just declare a function returning an array like a normal function, like Java: public String[] funcarray() { String[] test = new String[]{"hi", "hello"}; return ...
13
votes
3answers
8k views

Difference between passing array and array pointer into function in C

What is the difference between the two functions in C? void f1(double a[]) { //... } void f2(double *a) { //... } If I were to call the functions on a substantially long array, would these ...
9
votes
3answers
4k views

Can you store a function in a PHP array?

e.g.: $functions = array( 'function1' => function($echo) { echo $echo; } ); Is this possible? What's the best alternative?
1
vote
4answers
153 views

Manipulate multidimensional array in a function

I read a lot of stuff in here and tried many but i couldn't find a way to pass a multidimensional array to a function in C,change some of the values and somehow return the new array. It's important to ...
13
votes
2answers
15k views

PHP get all arguments as array?

Hey, I was working with a PHP function that takes multiple arguments and formats them. Currently, I'm working with something like this: function foo($a1 = null, $a2 = null, $a3 = null, $a4 = null){ ...
2
votes
8answers
4k views

C++ return array from function

I need to read in an array to my function, extract the data, and then return an array from the function. The array will only ever hold 2 values. This is what I want to do in concept: int ...
42
votes
8answers
188k views

Array functions in jQuery

I am using jQuery in my web application. I want to use arrays, but I am not able to find out functions for arrays (add, remove or append elements in array) in jQuery. Is there any link related to ...
13
votes
1answer
3k views

Given an array of arguments, how do I send those arguments to a particular function in Ruby?

Forgive the beginner question, but say I have an array: a = [1,2,3] And a function somewhere; let's say it's an instance function: class Ilike def turtles(*args) puts args.inspect end end ...
10
votes
2answers
660 views

Code-Golf: one line PHP syntax

Explanation PHP has some holes in its' syntax and occasionally in development a programmer will step in them. This can lead to much frustration as these syntax holes seem to exist for no reason. For ...
12
votes
2answers
3k views

Pass arguments from array in php to constructor [duplicate]

Normally, if I want to pass arguments from $myarray to $somefunction I can do this in php using call_user_func_array($somefunction, $myarray); However this does not work when the function one ...

1 2 3 4 5 6
15 30 50 per page