arrays

C array declaration and assignment?

I've asked a similar question on structs here but I'm trying to figure out how C handles things like assigning variables and why it isn't allowed to assign them to eachother if they are functionally the same. Lets say I have two arrays: int x[10]; int y[10]; Why won't x = y compile? If they are both the same "signature" like that,...

Arrays in Objective-C main method. Sigserve errors. Newb.

In Objective-C how should I best approximate what in Java I am doing like this: static private String[] array {"A", "B", "C"}; What I think I need is a simple array that I can index into with some integers. Alternative suggestions are welcome, but bear in mind that if I am getting stuck on this then I am pretty much hopeless anyway...

Array always comes back as empty [PHP]

below is my register form for my game and it is looking for errors that the user may have done, but even if an error is found it wont add it onto the $errors array. When I print_r the array it returns empty. I believe something is going wrong with the if functions because if I add a value into the array from outside one of the if functi...

An array of unknown size holding items with variable numbers of values/properties

I'm using a datatable where for each row I want to store some 3 or 4 fields, the fields are of different types, best case number of fields is 3, and I want to note the row_index (of the row in the datatable) as I need it. So like this I want to store the values (for the fields) for all the rows in the datatable. Please give me an examp...

Return an Array of Arrays via PHP WSDL based web service

I'm struggling with the following problem: I have a PHP-based web service which needs to be consumed by various clients. As long as I keep things simple, everything works fine. I figured that Axis2 and .NET don't like soapenc:array definitions in WSDL, so I created list types for mapping object arrays: <xsd:complexType name="CourseList...

Is it possible to declare a const of an array in BOTH Delphi and FreePascal without having the elements be constants?

A long time ago I remember I could do this in Turbo Pascal 7. Maybe I'm wrong and it's something I need to clarify, but is it possible to declare an array of strings as a constant? If not what's the option/workaround. What I have now is: type TStates = (sOne, sTwo, sThree); var TArrayOfString: array [sOne..sThree] of string = ...

Determine array size in constructor initializer

In the code below I would like array to be defined as an array of size x when the Class constructor is called. How can I do that? class Class { public: int array[]; Class(int x) : ??? { } } ...

Jquery with JSON Array - convert to Javascript Array

Hi, I've the following XML output from an asp.net webservice: <ArrayOfArrayOfString><ArrayOfString><string>1710</string><string>1711</string><string>1712</string><string>1713</string></ArrayOfString><ArrayOfString><string>Teleszkóp 350mm gázas</string><string>Teleszkóp 150mm olaj</string><string>Teleszkóp 260mm olaj sárga</string><strin...

Split array into smaller arrays.

I am looking for a way to easily split a python array in half. So that if I have an array: A = [0,1,2,3,4,5] I would be able to get: B = [0,1,2] C = [3,4,5] ...

About character pointers in C

Consider this definition: char *pmessage = "now is the time"; As I see it, pmessage will point to a contiguous area in the memory containing these characters and a '\0' at the end. So I derive from this that I can use pointer arithmetic to access an individual character in this string as long as I'm in the limits of this area. So why...

Error on defining an array even though its set via a Constant...

Hi, I know this is really basic, but its got me stumped... In Objective-C I'm trying to write: const int BUF_SIZE = 3; static char buffer[BUF_SIZE+1]; But I get a storage size of buffer isn't constant. How do I make Xcode realise that I'm setting it to a constant, + 1...? Or is this not possible...? Thanks...! Joel ...

Arrays of structs or native data types in Objective C

I've run into this problem a couple times now. Last time, I wanted to create an array of arrays (matrix) of BOOL's. I ended up encapsulating them in NSStrings, because apparently NSArray only has arrays of objects. This time, want an array of arrays again, but of CGPoints. I'm going to be using these to draw images to the screen...

How to add element to C++ array?

i want to assign an int into an array, but the problem is i dont know what is the index now. int[] arr = new int[15]; arr[0] = 1; arr[1] = 2; arr[2] = 3; arr[3] = 4; arr[4] = 5; that codes work because i know what index i am assigning to, but what if i dont know the index.. in php i can just do this arr[]=22; this will automaticall...

what's the best way to convert a ruby hash to an array

Hi All, I have a ruby hash that looks like this { "stuff_attributes" => { "1" => {"foo" => "bar", "baz" => "quux"}, "2" => {"foo" => "bar", "baz" => "quux"} } } and I want to turn it into a hash that looks like this { "stuff_attributes" => [ { "foo" => "bar", "baz" => "quux"}, { "foo" => "bar", "baz" => "quux"...

Can you resize a C++ array after initialization?

I'm learning to program, and C++ is my first language. Don't bother using pointers to show me - I don't understand them yet, and won't bother until I have more free time to dedicate to this. int mergeSort() { const int n = 9; int originalarray[n] = {1, 3, 5, 7, 9, 2, 4, 6, 8}; const int halfelements = (sizeof(originala...

[iPhone] Objective-C array of objects misbehaving (EXC_BAD_ACCESS) in TableViewController

Hello stackoverflow. I'm new to Objective-C, and I can't figure out why the NSString objects in my array of Car objects seem to have been released. Here's my Car.m class: #import "Car.h" @implementation Car @synthesize categoryId; - (id)initWithPrimaryKey:(NSInteger)pk categoryId:(NSNumber *)catId carName:(NSString *)n { if (self...

Why does this code compile and run successfully it seems it should get an index out of bounds.

I was reading through some java code in a project I was working on and came along a method with something to this effect in it. Object[] objs = null; objs[0] = str1; objs[1] = obj1; for(String str: strArray) { objs[objs.length+1] = str; } I can't figure out what is going on here. I was hoping someone could explain how this code i...

Fortran 90, Questions about Array & Derived Type

I have questions about Arrays and Derived Types. For my new project, I have to use an array instead of a scratch file to store information from users. To do this, I need to create derived types, too. However, I haven't understood what an array is and what a derived type is, how to use them, what they can do, and some other basic ideas. ...

VB.NET Image array using project resources

I need to make an array of images using references to the resources folder. The following is my code which does not work: Dim imgPictures(8) As Image imgPictures(0) = Image.FromFile(My.Resources.cat_1.ToString) How do I reference the images sitting in the resouces folder for this task? Cheers ...

Zend Framework: How to unset data rows in a Zend_Db_Table_Rowset object

I would like to iterate over the data rows stored in a Zend_Db_Table_Rowset object and then drop/unset some of the rows, if they don't fulfil certain criteria. I could use toArray() to get only the data rows from the object and then it would be easy to unset the rows I don't need. But since I want to keep my object for further use I don...