arrays

Is it possible to deallocate a statically defined array?

Can you release the memory of an array defined with static allocation? ...

Index was out of bounds. For Loops and Arrays

I'm trying to create two arrays filled with a set of strings from twos tables in a database and then compare them. For example (array1[0]=1101 and array2[0]=0110). If the both respective characters =1 then perform an action. But when I run this code I receive the error Index was outside the bounds of the array. System.IndexOutOfRangeExce...

Get the number of elements in a pointer to a char array in C++

I realise this is an incredibly noob question, but I've googled for it and can't seem to find an answer (probably because I've worded the question wrong... feel free to fix if I have) So I have this code: int main(int argc, char* argv[]) { puts(argv[1]); return 0; } It works fine if I've passed a parameter to my program, but ...

To understand: From PHP Array to Python ?

This is Common task In PHP and other programming languages.I moved from PHP developer. I want to make sure with this collections. Anyone have who good in python please help me to understand clearly . This is my collections from PHP code. <?php $php = array(1,2,3,4,5,6,7,8,9,10); for ($i = 0; $i < 10 ; $i ++) echo $php[$i]."<br>"; ?> =...

Javascript-How to get the second larger integer by "array"?

"Find the two largest values among the 10 digits entered. p.s. Use 'prompt' to get the integer from user." I would like to solve this question by "array", not "if", what should I do? I have tried, but error..... <script type="text/javascript"> var a, b, c; var arr = new Array[3]; arr[0] = a; arr[1] = b; arr[2] = c; a = window.prompt("...

remove line from array by key

How can i remove a line from an array where the key name = a given target...such as [name] => super [price] => 65.87 [quantity] => 25 [addtocart] => 1 say i wanted to remove the [addtocart] => 1 part ...

Similarities and differences between arrays and pointers through a practical example

Given the following code: #include <stdio.h> #include <stdlib.h> int main() { int a[1]; int * b = malloc(sizeof(int)); /* 1 */ scanf("%d", &a); printf("%d\n", a[0]); /* 2 */ scanf("%d", &b); printf("%d\n", b[0]); return 0; } the following warnings are obtained when it is compiled (i686-apple-d...

js adding a value to a element in an array

hi guys!! I found some answers to similiar questions but I'm still not getting it. but I hope it's a short problem so I dont make too much trouble! ;-) I have a js array arr = [ a, b, c] How can i add value to this elements dynamically? For example I want that each element get the value true So it should look like this afterwards:...

How to convert string "brakemeup" in to char[stringlength] array?

if i have this code, how can i put alle the chars in my string in to the Char array? i know this wont compile but the logic shows what im trying to do. private void button1_Click(object sender, EventArgs e) { string stringX = textbox1.Text; int strlen = stringX.Length(); char[] arrayX = new char[strlen...

How to get .NET array type from the string "string[]"?

Given the string "string[]" and asked to get the underlying Type for this class, one might start with: private Type getTypeByName(string typeName) { if (typeName.EndsWith("[]")) { return something; // But what? } return Type.GetType(typeName); } What type is "string[]" and how does one reflect the type out...

array_splice() for associative arrays

Say I have an associative array: "color" => "red" "taste" => "sweet" "season" => "summer" and I want to introduce a new element into it: "texture" => "bumpy" behind the 2nd item but preserving all the array keys: "color" => "red" "taste" => "sweet" "texture" => "bumpy" "season" => "summer" is there a function to do that? Array_...

growing matrices columnwise in numpy

In pure python you can grow matrices column by column pretty easily: data = [] for i in something: newColumn = getColumnDataAsList(i) data.append(newColumn) numpy's array doesn't have the append function. The hstack function doesn't work on zero sized arrays, thus the following won't work: data = numpy.array([]) for i in some...

BlackBerry: creating a dynamic no. of buttons based on the contents of a vector

Hi, based on the contents of a vector(IDs), i'm trying to create the corresponding no. of buttons but I'm having problems doing that. I was wondering if anyone could help? Below is the code that i'm using to try to get that done... ButtonField[] btn = new ButtonField[list.IDs.size()]; for(int i=0; i<list.IDs.size(); i++){ btn[i].s...

Calculate possible combinations of an array in order of presented arrays

This is a php question. I have an array of arrays: Array ( [1] => Array ( [1] => 1 [2] => 2 [3] => 3) [2] => Array ( [4] => 4 ) [3] => Array ( [7] => 7 [8] => 8 [9] => 9 ) [4] => Array ( [36] => 36 ) ) I need to make all possible combinations in order but never out of order, and never missing a previous possible..that likely a bad exp...

Arrays in Generic class

Is there any disadvantages in using array in generic class? If yes, what are they? If No what are the advantages? ...

When my C# form crashes it tries to create a new instance of itself

Hi, I do some rather long winded things with a forms application using arrays and sometimes I address it wrongly during development, instead of an obvious error or a crash the whole application restarts and tries to run: Application.Run(new SplashForm()); Why does this happen? It makes debugging very painful! Thanks ...

What is the appropriate data structure for this array in CSharp?

Hey guys, If I've got this data structure in PHP, what data structure is the best for it in C#? $array = Array( [dummy1] => Array ( [0] => "dffas", [1] => "asdas2", [2] => "asdasda" ), [dummy2] => Array ( [0] => "asdasd", [1] => "sdfsdfs",...

Generating word stacks from arrays

I'm trying to do a simple word cloud exercise in PHP but with little twist. I have everything else done but I can't figure out how to do a loop that combines the words. Here's example that will make it little bit easier to understand what I'm trying to do: I have array like this: $arr = array('linebreak','indent','code','question',...

PHP/MySQL - Storing array in database

Hi, I'm working on a PHP app which requires various settings to be stored in a database. The client often asks if certain things can be added or changed/removed, which has been causing problems with the table design. Basically, I had a lot of boolean fields which simply indicated if various settings were enabled for a particular record...

Difference between [square brackets] and *asterisk

If you write a C++ function like void readEmStar( int *arrayOfInt ) { } vs a C++ function like: void readEmSquare( int arrayOfInt[] ) { } What is the difference between using [square brackets] vs *asterisk, and does anyone have a style guide as to which is preferrable, assuming they are equivalent to the compiler? For completene...