arrays

Casting a 'BigStruct' to a 'SmallStruct' in C (similar structs with static arrays of different sizes)

Supposed that for some reason you are only allowed to use static memory in a C program. I have a basic structure that I am using in several places defined as below: #define SMALL_STUFF_MAX_SIZE 64 typedef struct { /* Various fields would go here */ ... double data[SMALL_STUFF_MAX_SIZE]; /* array to hold some data */ } Small...

C++ strcmp array

Hi I am using strcmp as shown below. I am debugging the values and which are coming same but still not getting that condition true. const char opcode_read[2] = {'0', '1'}; rc = recvfrom(s, blk_receive_full, sizeof (blk_receive_full), 0,(struct sockaddr FAR *)&sin, &fromlength); if(rc == -1){ printf("failed: recvfrom, \n No data rec...

Stack footprint of an array of types in C

I have the following function void DoSomething(int start[10], int end[10]) When I call it via void Do(void) { int start[10] = {1,2,3,4,5,6,7,8,9,0}; int end[10] = {1,2,3,4,5,6,7,8,9,0}; DoSomething(start,end); } do I put two pointers (8 byte all together) or two arrays each of 40 bytes in size on the stack? ...

Populating an array of hashes with arrays of hashes

I am currently developing a piece of monitoring software that takes an input file of server names and ip addresses and creates a rudimentary database of information. I want to default some values as it processes the config file and it works fine for the first time round the loop but any subsequent entries get created with weird (well wei...

Add an associated pair to a PHP array

I have an array, i tried writing array_push($json['Request']['Header'], "key" => "val"); but i received an error. Writing the below works but it adds an array instead of just the key/val array_push($json['Request']['Header'], array("key" => "val")); .. [0] => Array ( [key] => val ) //i would like ... [ke...

Bash: Join elements of an array?

If I've got an array like this in Bash: FOO=( a b c ) How do I join the elements with commas? For example, producing a,b,c. ...

How do I create an array containing indexes matching a criteria?

given: var args = new string[] { "-one", "two", "three", "-four" }; what would magic function need to look like in order to make the following pass? var result = MagicFunction(args); Assert.AreEqual(0, result[0]); Assert.AreEqual(3, result[1]); Assert.AreEqual(2, result.Length); ...

Adding Rows to Gridview without using databind

Hello, I have a gridview inside of a listview predefined in the xaml: .... <ListView x:Name="listPriority" IsSynchronizedWithCurrentItem="True" Margin="0,30,0,4" BorderThickness="0,0,0,0"> <ListView.View> <GridView> <GridViewColumn x:Name="grvPriorityColumn" Width="140" Header="Priority" /> <GridViewColumn x:Name="grvMessage" Wid...

How to sort an array of objects in PHP?

Say I have a group of people, each person having a name, sex, and age property, coded like this: public class Person { private $name, $sex, $age; public function Person ($name, $sex, $age) { $this->name = $name; $this->sex = $sex; $this->age = $age; } public function getName(); public function ...

Length of an Array in Objective C

I haven't found answer in any of the questions asked. I am passing an Integer Array to a function.Now I want to traverse through the array.But as things worked in C,C++ by simple using arrayname.length which gave the number of elements in array. What is the way to find that? [NSArrayObject length] works for NSArray type but I want it for...

build-in extractColFromArray?

Is there an equivalent build-in function to that one? (even without the test capability) /** * extracts a column from a 2D associative array, with an optional selection over another column * * @param $aArray array to extract from * @param $aColName name of the column to extract, ex. 'O_NAME' * @param $aColTest (optional) n...

delphi - how to use declare and use pointer to the const array in a const record?

Hi, I have a few const arrays of the same base type but different sizes, and I need to point to them in the const records. The code below compiles successfully, but finishes with error. type Toffsets = array of integer; Trec = record point1: Tpoint; //complete size point2: Tpoint; aOf...

Definition of mathematical operations (sin…) on NumPy arrays containing objects

I would like to provide "all" mathematical functions for the number-like objects created by a module (the uncertainties.py module, which performs calculations with error propagation)—these objects are numbers with uncertainties. What is the best way to do this? Currently, I redefine most of the functions from math in the module uncerta...

How can I assign the result of a subroutine call to array references in Perl?

Is it possible to assign an array variable to an array reference instead of to scalar variables? Instead of this: ($a, $b) = some_sub(\@d, \@e); I want something like this: (@x, @y) = some_sub(\@x1, \@y1); If so, how can I dereference it.where as in case of former, @$xxxx does for us. Thanks. ...

Mapping to an element of an array

I have a class Parent wich contains an array of 3 Child class objects (Child[] ChildArray). I have a Database Table MyTable with fields [FLD_01], [FLD_02], [FLD_03]. How do I map [FLD_01] to ChildArray[0], [FLD_02] to ChildArray[1] etc? ...

putting data from 2 classes into one array with 2 packages

Ok. since my confusion has died down i think i may have worded my question wrong. i have the classes "GenericMessage" "email" and "fax" in one package. "email" and "fax" have one variable in them which is a String. all of the above classes are in a package named "Message". now i have created a new package named "Outbox" it contains ...

JRuby Array to Java Array

Hey, I am making a site in JRuby on Rails, I am using some Java classes as well. I have a select form element which passes user selections to the controller. The selections are passed like so: Parameters: {"options"=>["Option One", "Option Two"]} The Java method that I am using requires the options selected to be a String[] (Java S...

Is there a function make a copy of a PHP array to another?

Is there a function make a copy of a PHP array to another? I have been burned a few times trying to copy PHP arrays. I want to copy an array defined inside an object to a global outside it. ...

Algorithm: efficient way to remove duplicate integers from an array

I got this problem from an interview with Microsoft. Given an array of random integers, write an algorithm in C that removes duplicated numbers and return the unique numbers in the original array. E.g Input: {4, 8, 4, 1, 1, 2, 9} Output: {4, 8, 1, 2, 9, ?, ?} One caveat is that the expected algorithm should not required the...

Write a class using a two-dimensional dynamic array...

I have a homework assignment. I'm not looking for anyone to do the work for me, I'm just having trouble with one little aspect, although I'd accept advice on other bits as well. The assignment is: Write a class using a two-dimensional dynamic array. The constructor passes in the dimensions of the array. The constructor also int...