typedef struct unit_class_struct {
char *name;
} person;
person * setName() {
person * array;
array = malloc (2 * sizeof(person));
array->name = strdup("Robert");
array++;
array->name = strdup("Jose");
return array;
}
int main()
{
person *array;
arra...
What I want to do is ask the user for a number of strings to read into an array, and then ask the user to input that number of strings and read them into the array. When I run this code it never asks me for an input the first cycle of the first for-loop, just prints out "String #0: String #1: " and then I can input text. Why is that and ...
Is it possible to have a (fixed) array which stores its elements in the read-only segment of the executable and not on the stack? I came up with this code but unfortunately it is very unflexible when it comes to adding, moving or deleting items. How do I verify that the strings are indeed stored in the read-only segment? I tried readelf ...
Woohoo, I've come to arrays now, thank god.
Now, I've got 2 arrays!
int colorvalues[][] = {{34,255,255,56},{127,204,11,34},{123,98,127,34},{34,34,127,17}};
Imagine it as a 4x4 pixel picture
Now, I want to create a histogram, the distribution of colorvalues from 0 to 255. For example here I've 2*255, 2*127, 5*34 and so on.
So I've ...
I'd like to have my array items scrambled.
Something like this:
[1,2,3,4].scramble => [2,1,3,4]
[1,2,3,4].scramble => [3,1,2,4]
[1,2,3,4].scramble => [4,2,3,1]
and so on, randomly
...
Note: No jQuery
How could i do something like this:
var array = new Array();
array[name] = "Tom";
array[age] = 15;
foreach(array as key=>value){
alert(key + " = " + value);
}
...
Im stuck, been trying to figure this out for 2 hours now. I have figured out the foreach loop, but cant figure out how to insert the data now.
here is my php, what am I doing wrong?
$query = "INSERT INTO images (thumb_path, image_path, main_image, project_id) VALUES ";
foreach($_POST as $key => $value) {
$query .= "$thumb_pat...
Hi, and first of all, thank you for taking the time to read my question.
I am trying to write a script, and I've come across an issue which I am finding hard to solve. I am working with a pair of numbers (for example, 1000 and 2000), and I have an array of pairs of numbers:
$pairs = array(
array(800, 1100),
array(1500, 1600),
...
I have created a 2D array and want to print the output. I want to label the columns and rows. I have labeled the rows. but I can not figure out how to label the columns. Something link this:
A B C D E F
Row 1 * * * * * *
Row 2 * * * * * *
Row 3 * * * * * *
Row 4 * * * * * *
Row 5 * * * * * *
Row 6 * * * * * *
Row 7 * * * * ...
Hey guys!
Now I have one trouble for develope one iPhone app.
I need to compute 150 parts and draw it on canvas.
I have code like this:
for (int i=x1; i<=x2; i++) {
for (int j=y1; j<=y2; j++) {
x=[NSNumber numberWithInt:i];
y=[NSNumber numberWithInt:j];
BoxCach...
The code below compiles, but immediately crashes for reasons obvious to others, but not to me. I can't seem to get it right, can anyone tell me how to fix this.
*array_ref[2] = array[0];
*array_ref[3] = array[1];
It crashes on that part everytime.
typedef struct test {
char *name;
char *last_name;
} person;
int setName(per...
How would you take a reference to an array slice such that when you modify elements of the slice reference, the original array is modified?
The following code works due to @_ aliasing magic, but seems like a bit of a hack to me:
my @a = 1 .. 10;
my $b = sub{\@_}->(@a[2..7]);
@$b[0, -1] = qw/ < > /;
print "@a\n";
# 1 2 < 4 5 6 7 > 9 10
...
Ok, I've been google'ing the web and I just can't seem to find any solution to my problem. I found lots of solutions, just not any that fit.
I need to create an array of generics. But the generic type itself extends Comparable. When I try the following :
public class Hash<T extends Comparable<String>> {
private T[] hashTable;
priv...
I have,
int[10] oneDim = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}, index = 0;
as shown here, we create the the two dimensional one from the origin. But how do I iterate my oneDim inside for (index = 0; index < 10; index++) so that I could get my column index and row index there without creating a new one?
I want it looks like this while print...
I have a homework problem Im 75% done with. My problem is that I cannot find a way to correctly display the correct value for the lowest population value and the province that has it. (Thanks in advance.):
*
Write a program to read in the
province data file into an array
called provinceName and an array
called provincePopulations. Y...
hi friends,
This is a code from my c# web application
<%
var text = File.ReadAllText(@"D:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\test.html");
Regex regex = new Regex("href\\s*=\\s*\"([^\"]*)\"", RegexOptions.IgnoreCase);
MatchCollection matches = regex.Matches(text);
//Response.Write...
I have a PHP array that I need to sort. I have included the example array below. I need to put the top 10 number of URLS plus their perspective counts in a different array. I know I could run into problem if there aren't 10 top matches ... if that happens then a random matching would be fine.
Any suggestions?
I have tried sort(myarra...
C# problem. I have an array
char[] x = {'0','1','2'};
string s = "010120301";
foreach (char c in s)
{
//how to check if c is in x, a valid char. ????
}
Thanks.
...
Hello,
How can i generate dynamically this array.
var posX:Array = [0,-20,20,-40,0,40,-60,-20,20,60,-80,-40,0,40,80,-100,-60,-20,20,60,100]
The numbers in the array refer to the x position of the object. I use it to place objects in triangular formation.
0
-20 20
-40 0 40
-60 -20 20 60 etc
Thank you in advance
...
Hi, just wondering if there is any way of checking if Value A is equal to ANY value within an array (without using large loop functions) - sort of like a "Where" function.
e.g.
if (DataRow[column1value] == <any value within>Array A[])
{
//do...
}
Cheers!
...