1
голосов
4ответов
2434 просмотров

Putting strings into a 2D chararray in C

How do I put strings into an 2D char array from (for example) a file? char buffert[10][30]; int i = 0; while(!feof(somefile)) { fscanf(somefile, "%s", temp); buffert[i][] = temp; i++; } This will not do it.

2
голосов
4ответов
22208 просмотров

creating dynamic Arrays Javascript

Hello i want to create a array in java script withing 2 for loops var i; var a; var total = document.getElementsByName('qm[7]') var creativity = document.getElementsByName('qm[0]'); var design = document.getElementsByName('qm[1]'); var text = document.ge...

2
голосов
3ответов
2668 просмотров

How to return a Ruby array intersection with duplicate elements? (problem with bigrams in Dice Coefficient)

I'm trying to script Dice's Coefficient, but I'm having a bit of a problem with the array intersection. def bigram(string) string.downcase! bgarray=[] bgstring="%"+string+"#" bgslength = bgstring.length 0.upto(bgslength-2) do |i| bgarray << bgstring[i,2] end return bgar...

1
голосов
1ответов
142 просмотров

arrays of structs need advice

I made an array of structs to represent map data that gets drawn; however I didn't double check it till it was too late: when I load in a new map I get either an "out of memory exception" (if i try to make a new array struct first) or I get a screwed up map that would require a lot of recodeing t...

24
голосов
7ответов
9573 просмотров

Is there a standard function in C that would return the length of an array?

Is there a standard function in C that would return the length of an array?

4
голосов
4ответов
2075 просмотров

Dynamic arrays size and dynamic arrays allocators in VC++

I'm confused a little while writing own tiny discovering program to clear up how Visual C++ allocates the memory for dynamic arrays. I must note, I have never met technical documents that describe this question on new[]/delete[] operators for any C++ implementation. Initially I thought that new[...

1
голосов
5ответов
671 просмотров

ASP.NET which type of collection should I use?

I am writing a class to save searches on my site. I want to have in the class an "Array" of all the parameters that were specified. I tried a NameValueCollection but the problem I ran into is when I have a multi-select (e.g. states) it only stores one of the entries because the key gets taken. I ...

18
голосов
5ответов
61868 просмотров

Creating array of objects on the stack and heap

Consider the following code: class myarray { int i; public: myarray(int a) : i(a){ } } How can you create an array of objects of myarray on the stack and how can you create an array of objects on the heap?

63
голосов
8ответов
146884 просмотров

C# equivalent of C++ map<string></string>

I want to keep some totals for different accounts. In C++ I'd use STL like this: map&lt;string,double&gt; accounts; // Add some amounts to some accounts. accounts["Fred"] += 4.56; accounts["George"] += 1.00; accounts["Fred"] += 1.00; cout &lt;&lt; "Fred owes me $" &lt;&lt; accounts['Fred'] &lt...

35
голосов
4ответов
155728 просмотров

Iterate through a C array

I have an array of structs that I created somewhere in my program. Later, I want to iterate through that, but I don't have the size of the array. How can I iterate through the elements? Or do I need to store the size somewhere?

461
голосов
19ответов
472424 просмотров

How to sort an array of associative arrays by value of a given key in PHP?

Given this array: $inventory = array( array("type"=&gt;"fruit", "price"=&gt;3.50), array("type"=&gt;"milk", "price"=&gt;2.90), array("type"=&gt;"pork", "price"=&gt;5.43), ); I would like to sort $inventory's elements by price to get: $inventory = array( array("type"=&gt;"pork",...

-2
голосов
2ответов
165 просмотров

Unexpected array behavior

The following modify method somehow modifies the whole @x array instead of just simply generating another element to be pushed later. How come? def modify i, s t = @x[-1] t[i] = t[i] + s t end @x = [ [10, 12] ] @x &lt;&lt; modify(0, 1) puts @x Edited The following code have done the tr...

4
голосов
5ответов
3298 просмотров

Difference Between int[] and list<int></int>

What is the difference between: int[] myIntArray and list&lt;int&gt; myIntArray ? In web services I read that I should pick one or the other and not mix the two, why?

23
голосов
3ответов
19456 просмотров

Fastest way to iterate array in PHP

I'm studying for the Zend PHP certification. Not sure the answer to this question. Question: What is the best way to iterate and modify every element of an array using PHP 5? a) You cannot modify an array during iteration b) for($i = 0; $i &lt; count($array); $i++) { /* ... */ } ...

0
голосов
1ответов
129 просмотров

NSArray atomfeed and categories

I have an atomfeed with which is succesfully getting parsed. All the articles are in the root array. But now I also have categories as a tag in the feed. How can I parse the atom xml so that the root array contains the categories and each category filters to an array with the corresponding artic...

0
голосов
3ответов
2446 просмотров

PHP Array overwriting values but need to add to array

The array: Array ( [0] =&gt; Array ( [0] =&gt; Service Simulators [1] =&gt; Array ( [0] =&gt; 1.php [1] =&gt; Title 1 ) ) [1] =&gt; Array ( [0] =&gt; Serv...

5
голосов
6ответов
10386 просмотров

Pattern Match on a Array Key

I need to get the stock values out of this array: Array ( [stock0] =&gt; 1 [stockdate0] =&gt; [stock1] =&gt; 3 [stockdate1] =&gt; apple [stock2] =&gt; 2 [ stockdate2] =&gt; ) I need to pattern match on this array, where the array key = "stock" + 1 wildcard character. I have tried using t...

2
голосов
6ответов
1341 просмотров

Java: How to be sure to store unique arrays based on its values on a List

I have a number of one dimension arrays of Object[] (these objects are primitive types if it helps) I want to store these arrays in a List, but only the arrays whose contents are unique from the rest. My first aproximation was to iterate througth the arrays storing in a Set the value of Arrays....

5
голосов
10ответов
19921 просмотров

What's the most elegant way to bubble-sort in C#?

Can this be cleaned up? using System; class AscendingBubbleSort { public static void Main() { int i = 0,j = 0,t = 0; int []c=new int[20]; for(i=0;i&lt;20;i++) { Console.WriteLine("Enter Value p[{0}]:", i); c[i]=int.Parse(Con...

1
голосов
7ответов
295 просмотров

How could a pointer to a structure be an array?

This is really a noob quick question. Imagine you have a struct called "No" and the following piece of code: No *v_nos; // What does this mean? Where I took this from they were calling "v_nos" a array? Isn't it simply a pointer to a struct "No"? Thanks.

1
голосов
1ответов
1759 просмотров

How do I convert a large array of 8 bit binary values in MATLAB?

This is a follow-up question to another SO question of mine. I have a large array of 8 bit binary values that I want to convert back to uint8. I have used Amro's lookupTable solution from the previous question. Now I want to do the reverse. I wanted to do a lookup table but sadly I am unable to...

1
голосов
4ответов
9073 просмотров

Filter 2D array by value of a particular key

How can I filter this array to only keep items with [category] =&gt; 1? [0] =&gt; Array ( [link] =&gt; index [image] =&gt; spot [category] =&gt; 0 ) [1] =&gt; Array ( [link] =&gt; test [image] =&gt; spotless [category] =&gt; 0 ) [...

0
голосов
5ответов
1790 просмотров

how to split multiple strings

im currently having troubles on my codes in C#. I want to split strings with no fix values. here' my code please help me fix this. protected void GridViewArchives_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { DataRowView ...

6
голосов
4ответов
3247 просмотров

Passing Static arrays as parameters for Dynamic arrays in Delphi

I have this array: const / var _Data : array [0..4] of array [0..3] of Double = ((0,0,0,0), (0,0,1,1), (1,0,1,0), (1,1,0,0), (1,1,1,1)); I wanna pass it as param value for this procedure: procedure NN.NetTraining(Data: TDoubleMatrix); Where: TDoubleArray = ...

0
голосов
4ответов
321 просмотров

Array to Hash or 2 binary element Array

I'm seeking the most concise way to do this Given the following Array: ['a','b','c'] how to get this: {'a'=&gt; 1,'b'=&gt; 2, 'c'=&gt; 3} and [['a',1],['b',2],['c',3]] I have few solutions at mind, just want to see yours :)

3
голосов
5ответов
7627 просмотров

Create array from the contents of <div> tags in php</div>

I have the contents of a web page assigned to a variable $html Here's an example of the contents of $html: &lt;div class="content"&gt;something here&lt;/div&gt; &lt;span&gt;something random thrown in &lt;strong&gt;here&lt;/strong&gt;&lt;/span&gt; &lt;div class="content"&gt;more stuff&lt;/div&gt...

0
голосов
2ответов
132 просмотров

Load a range of arrays (C#)

I need to keep track of how many items are in a node of this one attribute in C# and I have no idea on how to load an array, starting with 1 and ending with a variable The code for this portion is this //Loads file containing OSXInstaller File List doc.Load("Distribution.xml"); XmlNodeList Choi...

0
голосов
2ответов
307 просмотров

Array inside an array PHP SQL

I have tried everything I can think of for the last two days. I'm truly lost. I need to get this line of code to change based on my database. I have tried everything I could find on php.net and many forums. $Myday=&gt;array('/index.php?day=$Myday&amp;year=$MYyear','linked-day'), Any ideas ...

4
голосов
3ответов
3068 просмотров

Initialize Array to Blank custom type OCAML

ive set up a custom data type type vector = {a:float;b:float}; and i want to Initialize an array of type vector but containing nothing, just an empty array of length x. the following let vecarr = Array.create !max_seq_length {a=0.0;b=0.0} makes the array init to {a=0;b=0} , and leaving t...

7
голосов
3ответов
4880 просмотров

Fastest/One-liner way to remove duplicates (by key) in Ruby Array?

What's the fastest/one-liner way to remove duplicates in an array of objects, based on a specific key:value, or a result returned from a method? For instance, I have 20 XML Element nodes that are all the same name, but they have different "text" values, some of which are duplicates. I would lik...