I was wondering if there is any sample code out there for objective-C for implementing a NSMutableArray of type struct. Inside, I need there to be 2 mutable arrays (via NSMutableArray also) declared in the struct. All the code samples in my book show me how to make an array of defined size via C array syntax (with the brackets), but I do...
...without using typedef.
My boss claims he was once asked this in an interview, and when he gave his answer the interviewers told him he couldn't use typedefs because it was poor style.
Regardless, he likes to throw the question out at people just to see if they can get it right , usually at new programmer lunches. No one ever gets ...
Ok a pretty simple question.. in c++ it seems to work but in objective-c i seem to struggle with it :S ..
If you want to compare two arrays it should be something like this right
for ( int i = 0; i < [appdelegate.nicearray count]; i++ )
{
if ( appdelegate.nicearray[i] == appdelegate.exercarray[i] )
{
NSLog(@"the same elem...
how can I add key value pairs to an array?
This won't work:
public function getCategorieenAsArray(){
$catList = array();
$query = "SELECT DISTINCT datasource_id, title FROM table";
if ($rs=C_DB::fetchRecordset($query)) {
while ($row=C_DB::fetchRow($rs)) {
if(!empty($row["title"])){
...
Handling two dimensional arrays in Perl is giving me a headache. Anyway, the following is my question:
I have a loop which pushes an array, say @twoOneArray, into another array, say @twoDimArray, and then is reset before the next iteration of loop begins and then again is pushed into @twoDimArray with new set of values. When I print thi...
Hi all,
I'd like to be able to declare an array as a function argument in C++, as shown in the example code below (which doesn't compile). Is there any way to do this (other than declaring the array separately beforehand)?
#include <stdio.h>
static void PrintArray(int arrayLen, const int * array)
{
for (int i=0; i<arrayLen; i++) p...
I have this multi-dimensional PHP array (below).
Array
(
[0] => Array
(
[2] => [email protected]
)
[1] => Array
(
[4] => [email protected]
)
[2] => Array
(
[3908] => [email protected]
)
[3] => Array
(
[2548] => eleve...
Hi all, I would like to print out the data, for debugging purpose.
Data format would be like this
cntryCode = resArray("COUNTRYCODE")
business = resArray("BUSINESS") ' Payer's business name.
shipToName = resArray("SHIPTONAME")
the resArray consist of more than 10 records itself.
I tried to print out, but fail.
version 1 not w...
I am using the code below to draw an object to the stage. However I want to be able to redraw the object every time I press ENTER in my onEnterframe function. So I have to add the draw function again but with a new array. Also every time I push enter the value of the variables in the array should increase.
Here's the initial code:
maat...
i am using LINQ to SQL. My Database has 3 columns Ref, Due_amount, Due_Date.
Data may look like this, for example.
10 02/08/2009 00:00:00 175.0000
10 02/09/2009 00:00:00 175.0000
10 02/10/2009 00:00:00 175.0000
10 02/11/2009 00:00:00 175.0000
10 02/12/2009 00:00:00 175.0000
10 02/01/2010 00:00:00 175.0000
...
I have an array of ints like this: [32,128,1024,2048,4096]
Given a specific value, I need to get the closest value in the array that is equal to, or higher than, the value.
I have the following code
private int GetNextValidSize(int size, int[] validSizes)
{
int returnValue = size;
for (int i = 0; i < validSizes.Lengt...
I'm looking for a concise way to compare two arrays for any match.
I am using this comparison to apply a particular style to any table cell that has matching content. One array is a static list of content that should be contained in at least one table cell on the page. The other array is being generated by JQuery, and is the text of al...
I'm working on a project which uses Jersey to convert objects to JSON. I'd like to be able to write out nested lists, like so:
{"data":[["one", "two", "three"], ["a", "b", "c"]]}
The object I'd like to convert first represented data as a <LinkedList<LinkedList<String>>>, and I figured Jersey would just do the right thing. The above wa...
I want to write a method which can take an arbitrary array of a numeric type and return the sum of all the elements between startIndex and endIndex. This is what I have:
private static T SumArrayRange<T>(T[] scores, int startIndex, int endIndex)
{
T score = 0;
for (int i = startIndex; i <= endIndex; i++)
{
score += s...
At the moment I have a single array made up of multiple other arrays ie:
-- Category
-- Subcategory
-- Name
-- Count
-- Subcategory
-- Name
-- Count
-- Subcategory
-- Name
-- Count
-- Category
-- Subcategory
-- Name
-- Count
-- Subcategory
-- Nam...
Hi - I'm developing a property rentals website. The search results page will contain a list of property results. It is my intention to redefine the results, say by town, country, property type etc.
So let's say for example the user searches 'France'. All of the relative properties will be returned and displayed in a list.
However, I al...
i have 2 functions in a class, in the first one i have something like that:
public function func1() {
$test = array(1,2,3);
return $test;
}
how to copy the contents from $test in the second function?
public function func2() {
$newarray = $this->func1->test;
print_r($newarray);
}
Sorry, but i have really no idea, how to make this :...
Consider this code:
class arraytest {
public static void main(String args[]){
int[] a = null , b[] =null;
b = a;
System.out.println( b );
}
}
the line
b=a;
is flagged by the compiler saying:
Incompatible types, found int[], required int [][]
Why is b considered two dimensional? I realize the "shortcut" declarat...
When declaring an associative array, how do you handle the indentation of the elements of the array? I've seen a number of different styles (PHP syntax, since that's what I've been in lately). This is a pretty picky and trivial thing, so move along if you're interested in more serious pursuits.
1) Indent elements one more level:
$arr...
When I try to compile the following code I receive an error: "Type error in argument 1 to 'allocate'; found 'char * *', expected 'char *" at the line indicated (<<<<<). Explanations would be appreciated.
#include <stdio.h>
#include <string.h>
void allocate(char *dt);
int main(void)
{
char *data[3];
allocate(data); <<<<<
retu...