I have a program that contains the following piece of code for constructing an array of asterisks:
char array[Length][Height];
for (int count1 = 1; count1 <= Length; count1++)
{
for (int count2 = 1; count2 <= Height; count2++)
{
strcpy(array[count2][count3], "*");
cout << array[count2][count3];
}
}
cout << e...
I was thinking that dynamic arrays were a replacement for vectors in D, but it seems they have no remove function (only associative arrays do) which is rather a limitation for a vector so I'm wondering if I've got that right. If a have an array like follows,
uint[] a;
a.length = 3;
a[0] = 1;
a[1] = 2;
a[2] = 3;
Then the only way I've ...
Hi all,
I have a collection of keys in this massive flat single array I would like to basically expand that array into a multidimensional one organized by keys - here is an example:
'invoice/products/data/item1'
'invoice/products/data/item2'
'invoice/products/data/item2'
=>
'invoice'=>'products'=>array('item1','item2','item3')
how...
Question: Why can't I push elements into a 2d array that's inside of a while loop that parses through a SQL result set?
I need some help here as to why this happens. The way data is stored into a 2d array can be done several ways, but for my purposes, I need to use the push method.
Here's some code that works:
my @tt = (0,1,2,3);
my...
I realize that each argument passed from the command line is stored as a string in 'char *argv[]'
I'd like to pass
$ progname array[500]
and pull the string from argv[1] subsequently specifying an array based on what I read in.
Any ideas?
...
I need to store the input from a user into an array of strings.
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
char *history[10] = {0};
int main (void) {
char input[256];
input = "input";
strcpy(history[0], input);
return (EXIT_SUCCESS);
}
Running it on the terminal I get a Segmentation Fault and in ...
I have a problem. When I try to load a file into a string array nothing shows.
Firstly I have a file that on one line has a username and on the second has a password.
I haven't finished the code but when I try to display what is in the array nothing displays.
I would love for this to work.
Any suggestions?
users.txt
user1
password
use...
Hello all,
My developer friend told me of this site, and I'm hoping that perhaps someone might be able to help me solve a problem that I'm running into on any and all browsers while building the portfolio section of this website for my friend at her website which is (sorry for only being able to link one thing.... www - jennaschweitzer ...
I'm wondering if theres a method to determine whether a certain range of array elements is empty or not. for example, if the array was initialized with 10 elements having the values "", then if data was later assigned to elements 5, 7, 9; could i test if elements 0-3 were empty, or rather contained an empty string ""?
...
I want to store the byte value of aFloat in pixelsArray for each 3D coordinate, in a 1D array:
float aFloat = 1.0;
unsigned char* pixelsArray = new unsigned char[HEIGHT*WIDTH*3];
for (int i = 0; i < HEIGHT; i++)
{
for (int j = 0; j < WIDTH; j++)
{
for (int k = 0; k < 3; k++)
{
pixelsArray[?] = aFloat;
}...
I am trying to populate data from some csv files into a numpy array with the following code:
PreExArray=zeros([len(TestIDs),numColumns],float)
for row in reader:
if row[1] =='PreEx10SecondsBEFORE':
PreExArray[(j-1),0]=[row[2]]
However, the last line of code above throws the following error:
ValueError: setting an array e...
I am making a game using lite-C (exactly same syntax as C). and I cannot make this loop work.
It gives me an error at this line at compilation.
for(int i = 0; i < (cantenemigu * 3); i += 3)
I have an array with the information of where to create the enemies.
the array contains the x,y,z coordinates.
cantenemigu is the amount of enemi...
I have an array of pointers of CName objects. I have the following constructor which initializes my array to size one. Then when I add an object I grow the array by 1 and add the new object. It compiles fine, however when I try to print them I just get segmentation fault error. Can you look and see if I'm doing anything wrong?
//cons...
I've created a variable length array in one function, however I need to refer to this array in a second function. The problem occurs when I put the declaration above main() seeing as its length hasn't been defined yet, my compiler gets angry.
How does one typically go about this?
EDIT:
Here is my code so far.
I need to make the ar...
Hi,
I'm basically new to coding for random results, but did some reading and tested out the javascript version of the Fisher-Yates algorithm (as seen on wikipedia), with an ordered list.
I ended up adding code to make sure the array was shuffled differently than its initial order, and also calculated the percentage of how many objects ...
How would I go about finding the three most common elements in an array? I am working with an array of length 10,000 with elements = random integer from 0-100.
I was thinking of using two arrays, one of length 100 and just incrementing by using an if statement. However, I was wondering if there is a way that only one for/if loop(stateme...
Hi,
I wish to work with checked list views wherein only one item can be selected at a time. Some queries related to this:
1) Is it advised to work with CheckedTextView as the ListView items, or a combination of CheckBox and TextView?
2) If using CheckedTextView, the text comes first and the checkbox appears on right edge. Is it possib...
I am creating a 2d array full of zeros with the following line of code:
MyNewArray=zeros([4,12],float)
However, the first column will need to be populated with string-type textual data, while all the other columns will need to be populated with numerical data that can be manipulated mathematically.
How can I edit the code above so th...
I have many csv files which each contain roughly identical matrices. Each matrix is 11 columns by either 5 or 6 rows. The columns are variables and the rows are test conditions. Some of the matrices do not contain data for the last test condition, which is why there are 5 rows in some matrices and six rows in other matrices.
My appli...
Hi,
i'm trying to get the difference between two arrays, but with array_diff, array_diff_assoc, array_diff_key i can't get what i want..
Array 1 :
0 => 424012,
1 => 423000,
2 => 425010,
3 => 431447,
4 => 421001,
5 => 421002,
Array 2 :
0 => 424012,
1 => 423000,
2 => 425010,
3 => 431447,
4 => 431447,
5 => 421001,
...