arrays

Passing NSMutableArray to other classes

I have created an NSMutableArray in the implementation of my class loginController. The mutable array contains a set of strings. I want to pass the mutable array with its objects to other classes within my cocoa-project. What is the best way to pass the array? ...

Is it a best practice to wrap arrays and their length variable in a struct in C?

Hi, I will begin to use C for an Operating Systems course soon and I'm reading up on best practices on using C so that headaches are reduced later on. This has always been one my first questions regarding arrays as they are easy to screw up. Is it a common practice out there to bundle an array and its associated variable containing...

Need simple example of how to populate javascript array from Viewdata list

Hi - There may be a simpler way of doing this and I am all ears if there is. My situation is I have a dropdownlist on a form which I successfully populate with text and values. I also need to have additional related string values from the same table row in the db table available on the client so when the user selects from the dropdown t...

Unable to access property of NSArray in cocoa

I'm trying to pass an NSArray containing strings for use in another class than the one in which it is generated. Therefore I have made it a property as following: loginController.h #import <Cocoa/Cocoa.h> @interface loginController : NSObject { NSArray *myArray; } @property (nonatomic, retain) NSArray * myArray; @end log...

Multi-Dimensional Arrays

I am working in Java and am wondering, are multi-dimensional arrays like grids where rows are elements and columns are dimensions, or are they hyper-geometric figures that we can't see? ...

Error in returning a pointer from a function that points to an array

Greetings Everyone, I'm in a bit of a fiddle in that I dont know why my code brings up the following error when compiling: 1>..\SA.cpp(81) : error C2664: 'CFE' : cannot convert parameter 1 from 'int' to 'int []' 1> Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast Esse...

Should I store C array values in local variables if I'm going to reference them repeatedly?

I'm writing some optimized C code that basically runs through an array and does something to each element. What it does depends on the current value of the element so something like: for (i=0; i < a_len; i++) { if (a[i] == 0) { a[i] = f1(a[i]); } else if (a[i] % 2 == 0) { a[i] = f2(a[i]); } else { a[i...

C# equivalent for C code needed

Can anybody tell me the C# equivalent for this C code? static const value_string message_id[] = { {0x0000, "Foo"}, {0x0001, "Bar"}, {0x0002, "Fubar"}, ... ... ... } ...

copying strings into a buffer

Hello, I have some code that stack dumps when using sprintf to copy a a pointer to strings. I am trying to copy the contents of animals into a new pointer array called output. However, I get a stack dump. What should be in the output is the following: new animal rabbit new animal horse new animal donkey An I going about this the right...

Populate array of objects from namevaluecollection in c#

I am new to C#. Here is a hard-coded thing I got working: InputProperty grantNumber = new InputProperty(); grantNumber.Name = "udf:Grant Number"; grantNumber.Val = "571-1238"; Update update = new Update(); update.Items = new InputProperty[] { grantNumber }; Now I want to generalize this to support an indefinite number of items in the...

Converting a Bidimensional Array (Numbers) Into A Dimensional Array and Viceversa on Java

Hi everyone I'm in need of help right now. I need to convert 2 dimensional array of numbers to a one dimensional array in Java. Can anyone help me? Have a great day. :) ...

Why does my code return the error "missing : after property id" in JavaScript?

How is this supposed to be written so that it would actually work? saveBuyerInfo( { 'save_'+$("#textAreaXMLPostRequest").attr('name') : $("#textAreaXMLPostRequest").val() } ); ...

How does Simple XML use the [] operator?

In PHP you can use square brackets on an element to access attributes: $node = /* SimpleXMLElement */ $id = $node['id']; What's weird is that $id isn't a string, It's another SimpleXMLElement. Why isn't it a string? I find myself using strval() all over the place on this. How are the square brackets working? Can I do that with my own...

How To Convert a UniDimensional Array to a Bidimensional Array (Java)

I already have the code for how to convert a bidimensional one into a dimensional one, but I don't know how to do it vice-versa. Here's my code: package laboratorio9; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner entrada = new Scanner(System.in); int A[][]; int B[]; int...

Multidimensional Arrays in a struct in C#

I'm trying to convert the following (shortened for readability) to C# and running into problems #define DISTMAX 10 struct Distort { int a_order; double a[DISTMAX][DISTMAX]; }; I thought in structs it was a simple case of using "fixed" however I'm still getting problems. Here's what I've got (With a define higher up the page): ...

Save a list of user ids to a mysql table

I need to save a list of user ids who viewed a page, streamed a song and / or downloaded it. What I do with the list is add to it and show it. I don't really need to save more info than that, and I came up with two solutions. Which one is better, or is there an even better solution I missed: The KISS solution - 1 table with the primary...

Extract array from list in python

If I have a list like this: >>> data = [(1,2),(40,2),(9,80)] how can I extract the the two lists [1,40,9] and [2,2,80] ? Of course I can iterate and extract the numbers myself but I guess there is a better way ? ...

Serialize .NET Array to XML as base 64?

I'm writing a custom .NET serializer in C# and want to read and write Array objects to XML using XmlReader and XmlWriter. I would like to base64-encode the Array. The arrays may be 1-, 2- or 3-dimensional and the elements are bool or numeric types. I'm completely stumped. XmlReader and XmlWriter have methods for reading/writing Byte[] ...

Confused on C# Array of objects and implicit type conversion

I am trying to pass an array of a simple object to a web service and I'm really stuck on this error during compile of my web client project: Cannot implicitly convert type 'TRIMBrokerUtil.MetaData[]' to 'TRIMBrokerASMXProxy.ASMXProxy.MetaData[]' Here is my "utility" project compiled into TRIMBrokerUtil.dll: namespace TRIMBrokerUtil { ...

Use reflection to set the value of a field in a struct which is part of an array of structs

At the moment my code successfully sets the value of fields/properties/arrays of an object using reflection given a path to the field/property from the root object. e.g. //MyObject.MySubProperty.MyProperty SetValue('MySubProperty/MyProperty', 'new value', MyObject); The above example would set 'MyProperty' property of the 'MyObject' ...