arrays

Help with Two-Dimensional Arrays

First of all, Beginner here. I'm using this code. class MDArrays { public static void main(String[] args) { int[][] x; int t=2; x = new int[2][3]; for(int i=0; i<=1; i++) { for(int j=0; i<=2; j++) { x[i][j] = t; t += 2; System.out.println(x...

How Do I sort an NSMutable Array with NSNumbers in it?

I'm trying to make a high score table, and suck at arrays in objective c (actually, in general objective c is challenging for me), so I can't figure out how to sort. I'm trying to do something like this (speudocode, I'm writing this in actionscript style because I'm more comfortable with it): highscores.addObjecttoArray(score) highscore...

PHP post checkboxes help

I"m having trouble receiving a list of items that are checked in a field of checkboxes which are part of a form. I have an HTML table with a few checkboxes: HTML <input type="checkbox" name="carry[]" value="1" /> <input type="checkbox" name="carry[]" value="2" /> <input type="checkbox" name="carry[]" value="3" /> PHP - this is wh...

getting an array of cities out of a json response

I have the following code. I am trying to get just the name of the city out of the feed that is requested, and into a new array. Can anyone give me an indication. $city = $_GET['city']; $json = @file_get_contents('http://ws.geonames.org/searchJSON?country=GB&amp;maxRows=10&amp;name_startsWith=$city'); $json = utf8_encode($json); $c...

C++: Best way to copy a section of a large array into a smaller one?

I have a situation where I will need an amount of memory determined at runtime to pass to a function. I am using a larger buffer on the stack, then only creating on the heap the space that is necessary: Foo largeBuf[1024]; int sizeUsed = fillBuff(largeBuf, 1024); Foo* smallerBuf = new Foo[sizeUsed]; for (UINT i = 0; i < sizeUsed; i++...

What is the most efficient way to convert STL string array to const char* array?

We have: std::string string_array[2]; string_array[0] = "some data"; string_array[1] = "some more data"; char* cstring_array[2]; What is the most efficient way to copy data from string_array to cstring_array? Or pass string_array to the function, needed "const char* cstring_array[]"? ...

.NET - Copy from Unmanaged Array to Unmanaged Array

I've been looking through the Marshal class, but I can't seem to find a method that allows me to copy from an unmanaged array (IntPtr) to another unmanaged array (IntPtr). Is this possible using .NET? ...

How can I get this string to convert back into the array?

I am trying to use jMonthCalendar to add some events from an XML feed into a calendar. In the original jMonthCalendar, the events are in an array that looks like this: var events = [ { "EventID": 1, "StartDateTime": new Date(2009, 5, 12), "Title": "10:00 pm - EventTitle1", "URL": "#", "Description": "This is a sample event description...

Text file to string array in plain c?

I want to load a txt file into an array like file() does in php. I want to be able to access different lines like array[N] (which should contain the entire line N from the file), then I would need to remove each array element after using it to the array will decrease size until reaching 0 and the program will finish. I know how to read t...

Need Help With N Queens Program ( checking diagonals )

I'm working on an N Queens program that will allow the user to enter a Queen configuration as a String. For example, when prompted, the user might enter something like Q....Q.....Q..Q. which when displayed as a board would look like: Q . . . . Q . . . . . Q . . Q . Is not a solution! This program is simple in that it assumes that the ...

Array to XML in Php (using DOM)

Hi everybody, i just have a php array with number that i've "explode" to separate itens, $arr = array($_POST["fname"]); $arr = explode(',', $_POST['fname']); $parentesis; $parentesis2; for ($i = 0; $i < sizeof($arr); $i+=2){ `$parentesis = substr($arr[$i], 1);` `$parentesis2 = substr($arr[$i+1], 0,-1);` actually arays...

Undefined offset error, but offset is not undefined

I'm getting a Notice: Undefined offset: 0 error in my code, however I can print_r the element I am trying to get and its clearly defined. function get_members($entries_found) { $members = $entries_found[0]['member']; ... } If I print_r($members) I get the expected output, however I'm still getting the Notice. Any clues? ...

Array in VB .Net

I have an array Newstr(20) When I fill it, I need to know how many of its indexes has been filled ? and find out the values. ...

Linq: convert an list<int> to a string of ints?

I have an int array with the value 3,99,6. How do i convert the array into the string 3,99,6 with linq? ...

C# GetType().GetField at an array position

public string[] tName = new string[]{"Whatever","Doesntmatter"}; string vBob = "Something"; string[] tVars = new string[]{"tName[0]","vBob","tName[1]"}; Now, I want to change the value of tName[0], but it doesnt work with: for(int i = 0; i < tVars.Lenght;++i) { this.GetType().GetField("tVars[0]").SetValue(this, ValuesThatComeFromS...

If (Array.Length == 0)

If an array is empty, it looks like you can't check it's length using ".length". What's the best way to check if an array is empty? ...

Strange behaviour of the Array type

scala> List(1,2,3) == List(1,2,3) res2: Boolean = true scala> Map(1 -> "Olle") == Map(1 -> "Olle") res3: Boolean = true But when trying to do the same with Array, it does not work the same. Why? scala> Array('a','b') == Array('a','b') res4: Boolean = false I have used 2.8.0.RC7 and 2.8.0.Beta1-prerelease. ...

What is the fastest way to initialize an integer array in python?

Say I wanted to create an array (NOT list) of 1,000,000 twos in python, like this: array = [2, 2, 2, ...... , 2] What would be a fast but simple way of doing it? ...

array of streams in c sharp

Typically I declare streams inside of a using statement to ensure that the stream is properly disposed when I am done with it, and so that I don't mistakenly call it when I'm outside the using block. Some examples here: MSDN using Statement Reference How does one use a using statement with an array of streams? Would it be equivalent to...

How to pass Object array to unmanaged code?

I'm trying to pass an array of objects from C# to unmanaged C++, and nothing seems to work. The compiler won't let me pretend the array is an IntPtr. Casting the array to an IntPtr doesn't work. I've tried to pass the address of pinned data, but this didn't work either. I just need to pass a pointer to the beginning of the array, and...