arrays

bug-input 2d array using scanf in C

Whats wrong with this?I am getting segmentation fault during runtime. int size; scanf("%d",&size); int init[size][size]; //initial matrix for(int i=0;i<size;i++) for(int j=0;j<size;j++) scanf("%d",init[i][j]); ...

Dynamic Array of ints in j2me

I want to do a simple dynamic array of ints in my j2me application, The only dynamic array I see is "java.util.Vector" and this one doesn't seem to accept an int as a new element (only wants Objects). So how do I go around fixing that problem? ...

.NET / C# - Convert char[] to string

Guess I have just never run across it before. What is the proper way to turn a char[] into a string? The ToString() method from an array of chars doesn't do the trick. Guess I had always imagined that was what it was for. ...

What is the safest way to initialize bash arrays with quoted values from function output?

I prefer to program my bash scripts to be as procedural as possible. One difficulty I've encountered in trying to do so happens when passing array data between functions, a task that's not well supported in bash. As an example, it's trivial to initial an array in bash with multiple hard-coded, quoted values, each of which may contain m...

Detecting if an Array is Indexed or Associative

Possible Duplicate: PHP Arrays: A good way to check if an array is associative or sequential? What would be the most performant way of checking if an array is associative or not in PHP? ...

C# - LINQ How to return possible combinations list by removing Nulls ?

I have two arrays : string[] Group = { "A", null, "B", null, "C", null }; string[] combination = { "C#", "Java", null, "C++", null }; i wish to return all possible combinations like { {"A","C#"} , {"A","Java"} , {"A",C++"},{"B","C#"},............ } (null should be ignored). using LINQ. Help please. ...

Sizeof array passed as parameter

Given the following program #include <iostream> using namespace std; void foo( char a[100] ) { cout << "foo() " << sizeof( a ) << endl; } int main() { char bar[100] = { 0 }; cout << "main() " << sizeof( bar ) << endl; foo( bar ); return 0; } outputs main() 100 foo() 4 The questions: Why is the array passed as a point...

the best way to make codeigniter website multi-language. calling from lang arrays depends on lang session?

Hi friends, I'm researching hours and hours, but I could not find any clear, efficient way to make it :/ I have a codeigniter base website in English and I have to add a Polish language now. What is the best way to make my site in 2 language depending visitor selection? is there any way to create array files for each language and call...

Retrieve first key in multi-dimensional array using PHP

I would like to retrieve the first key from this multi-dimensional array. Array ( [User] => Array ( [id] => 2 [firstname] => first [lastname] => last [phone] => 123-1456 [email] => [website] => [group_id] => 1 [company_id] => 1 ...

Create an array of all the items in the sub arrays of an array of arrays?

Did I say "array" enough for you there? To clarify: I'm working on organizing and array in an iPhone project. I have an array of arrays. Each sub array has a list of items. How can I make a new array of all the items contained in the sub arrays? I've experimented with the addObjectsFromArray function with little luck. Thanks! ...

What are the Practical Differences Between "associate" and "indexed" Arrays in PHP?

The PHP array type is actually more akin to an an ordered map than a traditional C array. It's PHP's original general use data structure. The manual goes as far to say The indexed and associative array types are the same type in PHP, which can both contain integer and string indices. However, there's a lot of cases where built-in lang...

What is cross browser support for JavaScript 1.7's new features? Specifically array comprehensions and the "let" statement.

https://developer.mozilla.org/en/New_in_JavaScript_1.7 A lot of these new features are borrowed from Python, and would allow the creation of less verbose apps, which is always a good thing. How many times have you typed for (i = 0; i < arr.length; i++) { /* ... */ } for really simple operations? Wouldn't this be easier: [/* ... ...

Returning an Javascript Object's property by Value NOT Reference

So I have a class foo that has a method which returns an array bar. I have another function that calls foo.getBar and then filters the array. I want to be able to always get the original contents of bar when I use a different filter, but bing seems to be just creating a reference to bar, not a separate array. I have tried using return th...

Check whether an array is empty without using a loop?

Is there any function available in PHP to check whether an array is empty or how can I do this without using loop? For example: $b = array('key1' => '', 'key2' => '', 'key3' => '', 'key4' => ''); How can I check array $b contains empty values without using a loop? ...

Object Extension Methods on Value Types

Hi, I have an Extension Method: public static string ToDelimenatedString(this object[] array, string delaminator) {...} The Extension is applied to reference types but not value types. I assume this is because object is nullable. How would I write the method above to target value types, is it even possible without writing it out for ...

What is the right way to change an Integer in a Vector in Java (j2me)

As a follow up to my question about j2me dynamic arrays, I'm now trying to figure out a way to change the values of the Integers in my Vector. Say I have a Vector v, and Array arr, and ints x, y and i; In c++ I could do: v[arr[x][y]] += i; In j2me the best way I found so far to do the same is: v.setElementAt(new Integer(((Integer)...

Is the memory of a (character) array freed by going out of scope?

Very much related to my previous question, but I found this to be a separate issue and am unable to find a solid answer to this. Is the memory used by a (character) array freed by going out of scope? An example: void method1() { char str[10]; // manipulate str } So after the method1 call, is the memory used by str (10 bytes) fre...

C: differences between pointer and array

Hi, I know that similar questions are posted in SO, but I thought I can ask this in the following the context: char amessage[] = "now is the time"; char *pmessage = "now is the time"; I read from The C Programming Language, 2nd Edition that the above two statements don't do the same thing. I always thought that an array is an conven...

How to slice an array in bash

(edited to fit the answer) Looking the "Array" section in the bash(1) man page, I didn't find a way to slice a bash array. So I came up with this overly complicated function: #!/bin/bash # @brief: slice a bash array # @arg1: output-name # @arg2: input-name # @args: seq args # ---------------------------------------------- function...

jQuery JSON ASP.NET MVC Access Object with Array List Properties?

I have an object with 2 ArrayList properties. public class TestDTO { public ArrayList Test1 { get; set; } public ArrayList Test2 { get; set; } } I am returning the the object as JSON in my JsonResult Action. The SUCCESS from my AJAX call looks like the following but it does not appear to be working. What do I need to do to a...