Questions tagged as 'array'

3
answers

What is the advantage of using array include vs configuration file?

I have observed some codes where the programmer does the following: /** Arquivo A.php */ return array('databaseName' => 'bancoTeste', 'port' => 5208); /** Arquivo B.php */ $configs = include("A.php"); // Acesso as $configs echo $confi...
asked by 11.02.2015 / 12:15
3
answers

Passing vector to functions

How do I pass a vector to a function? Something that, in the Moon, would be like this: vector = {"V", "e", "t", "o", "r"} function getVector(vector, pos) return vector[pos] end print(getVector(vector, 1)) Output: "V" I tried this way:...
asked by 16.12.2014 / 00:35
2
answers

Problems with sizeof

I am trying to return the size of the array , but it is giving error. What to do? #include <stdio.h> char *palavra[] = {"casa", "carro"}; int main(){ int i; for(i = 0;i < sizeof(palavra);i++){ //Segmentation fault aqui....
asked by 19.01.2017 / 16:02
3
answers

Generate random numbers in an Array of 10 up to 50

How can I generate an array of random numbers with a limit, must be numbers from 10 to 50. To generate random numbers from 0 to 50 I use: Random random = new Random(); int array[] = new int[5]; // 5 números serão ger...
asked by 25.08.2015 / 16:58
4
answers

Separate an array into groups?

I have the following code answered by a question similar to this but I would like to upgrade, this is the current function: function separar(base, maximo) { var resultado = [[]]; var grupo = 0; for (var indice = 0; indice < base.leng...
asked by 19.05.2017 / 14:58
4
answers

Return Array with name of all files in directory

I need my HTML5 page to return a Array with all file names and extensions in a directory within my site. I can do this in other server-side languages, but I'd like to do it in JS. is there such a possibility?     
asked by 16.12.2013 / 19:33
1
answer

Array in PHP using () or []?

I always use the parentheses to define an array in PHP, such as: $array = array('a','b','c'); But every now and then I see some code here using brackets, like: $array = ['a', 'b', 'c']; However, if I use brackets, I get the error:  ...
asked by 01.05.2018 / 00:06
2
answers

ArrayList versus List

What's the point in C # should we give preference to using List instead of ArrayList ?     
asked by 09.08.2017 / 15:01
2
answers

How to know the array key of the 3 biggest results?

I have this array $qtd = array( 'acao' => $acao, 'aventura' => $aventura, 'comedia' => $comedia, 'drama' => $drama, 'faroeste' => $faroeste, 'ficcao' => $ficcao, 'suspense' => $suspense, 'terror' => $terror, 'romance' =...
asked by 08.11.2016 / 17:40
2
answers

Array is a pointer in C? [duplicate]

I'm reading a book about pointers in C, but since I'm new to such a language, the concept of pointers is a bit complex, and when I read the following definition, I came up with the question of whether an array is a pointer .    Pointer Var...
asked by 03.07.2017 / 15:18