arrays

Assigning a value to a variable gets stored in the wrong spot?

Hello, I'm relatively new to C, and this is baffling me right now. It's part of a much larger program, but I've written this little program to depict the problem I'm having. #include <stdio.h> int main() { signed int tcodes[3][1]; tcodes[0][0] = 0; tcodes[0][1] = 1000; tcodes[1][0] = 1000; tcodes[1][1] = 0; ...

Compact a given array problem

Dont know whether this is a duplicate, but this was an interview question asked to me. Given an array of random numbers and -1 placed inbetween, I have to compact the array meaning all the -1s are to be replaced and the final output should be the last valid index with the fresh array. For example. Input: 3 4 -1 -1 -1 5 8 -1 8 Output: 3 ...

VB 2008 - Index was outside the bounds of the array

Hey guys I'm having a problem while reading a config.cfg file of my program. I can read the 23. char of the file but I can't read the 24. char (last char in file). This is the code: Dim CFGReader2 As System.IO.StreamReader CFGReader2 = _ My.Computer.FileSystem.OpenTextFileReader(CurDir() & "\Config.cfg") Dim Server(2) As String Server(...

Is it OK to have HTML tags inside an array (is there risk of hacking)?

I have the following array: 'tagline_p' => "I'm a <a href='#showcase'>multilingual web</a> developer, designer and translator. I'm here to <a href='#contact'>help you</a> reach a worldwide audience.", Should I escape the HTML tags inside the array to avoid hackings to my site? (How to escape them?) or is OK to have HTML tags inside a...

How to include an anchor link inside an php array without breaking the array?

I included an anchor tag in the following php array: 'tagline_p' => "I'm a <a href='#showcase'>multilingual web</a> developer, designer and translator. I'm here to <a href='#contact'>help you</a> reach a worldwide audience.", tagline_p is repeated 3 times (3 different languages) in differente folders (lang.en.php, lang.es.php, and lan...

BASH, multiple arrays and a loop.

At work, we have 7 or 8 hardrives we dispatch over the country, each have unique labels which are not sequential. Ideally drives are plugged in our desktop, then gets folders from the server that correspond to the drive name. Sometimes, only one hard drive gets plugged in sometimes multiples, possibly in the future more will be added....

Convert an ArrayList to an object array

Hello, Is there a command in java for conversion of an ArrayList into a object array. I know how to do this copying each object from the arrayList into the object array, but I was wondering if would it be done automatically. I want something like this: ArrayList<TypeA> a; // Let's imagine "a" was filled with TypeA objects TypeA[] ar...

PHP display some items from an array

I have a big array which i need to display the latest 10 items in it only. what is the best php code to do that? thanks ...

How to create an array from database?

Hi, Please help me to create an array from a field of my DB. That field has records separated by comma. Below is the illustration: ID | article_title_fld | article_tags_fld | ---------------------------------------------------------------------- 1 | Learn PHP | PHP, coding, scripting ...

error unidentfied identfier "exams" and i dont know why in c++

error C2065: 'exam1' : undeclared identifier // basic file operations #include <iostream> #include <fstream> using namespace std; void read_file_in_array(int exam[100][3]); double calculate_total(int exam1[], int exam2[], int exam3[]); // function that calcualates grades to see how many 90,80,70,60 //void display_totals(); int main() {...

PHP Array logic re-factor

PHP Array logic re-factor I'm trying to re-factor my code... This is PHP ... I have the following: $totals[] = "Total"; $totals[] = $counts['hole'][1] + $counts['warn'][1] + $counts['info'][1] + $counts['crit'][1]; $totals[] = $counts['hole'][2] + $counts['warn'][2] + $counts['info'][2] + $counts['crit'][2]; $totals[] = $counts['hole'...

Deleting Part of An Array in Java to Free Memory on Heap

I am implementing a dynamic programming algorithm for the knapsack problem in Java. I declare the array and then initialize its size to be [number of objects][capacity of knapsack]. When my number of objects or my capacity gets too large, I get a memory error because I run out of space on the heap. My questions is: If I delete rows...

Array of Arrays in C#

I need to know how to initialize array of arrays in C#.. I know that there exist multidimensional array, but I think I do not need that in my case! I tried this code.. but could not know how to initialize with initializer list.. double[][] a=new double[2][];// ={{1,2},{3,4}}; Thank you PS: If you wonder why I use it: I need data str...

error LNK2019 and fatal error LNK1120 i get these errors in c++.

i have no idea how to get these errors out. i wrote the whole code over and tried to see if it was a problem with brackets but that doesnt help either. i dont know what line it is but i believe it is in this function. error LNK2019: unresolved external symbol "int __cdecl read_file_in_array(int (* const)[3])" (?read_file_in_array@@YA...

This program runs but not correctly; the numbers aren't right.

this program runs but not correctly numbers arent right, i read numbers from a file and then when i am using them in the program they are not right.:brief decription of what i am trying to do can someone tell me if something doesnt look right. this is what i have to do: write a program that determines the grade dispersal for 100 studen...

optimize 2D array in C++

I'm dealing with a 2D array with the following characteristics: const int cols = 500; const int rows = 100; int arr[rows][cols]; I access array arr in the following manner to do some work: for(int k = 0; k < T; ++k) { // for each trainee myscore[k] = 0; for(int i = 0; i < cols; ++i) { // for each sample for(int j = 0; j <...

Populating a PHP array within a foreach loop

I am wanting to add each user into an array and check for duplicates before I do. $spotcount = 10; for ($topuser_count = 0; $topuser_count < $spotcount; $topuser_count++) //total spots { $spottop10 = $ids[$topuser_count]; $top_10 = $gowalla->getSpotInfo($spottop10); $usercount = 0; $c = 0; $array = array(); foreach($top_10...

PHP in_array() can't even match a single character. Strict is set to true.

I've seen a million of these threads here already, and read through every single one. That, plus some serious Googling. UPDATE: I am rewriting this post to include complete code and explanation, so everyone understands what is going on and what I am trying to do. I am developing using CodeIgniter, so some syntax may look weird if you ...

C++ 2d Array Class Function Call Help

I hope this question takes a simple fix, and I am just missing something very small. I am in my second semester of C++ in college, and we are just getting into OOP. This is my first OOP program, and it is causing me a little problem. Here are the errors I am getting: Member function must be called or its address taken in function displ...

Get array's key recursively and create underscore seperated string.

Hello Everyone, Right now i got an array which has some sort of information and i need to create a table from it. e.g. Student{ [Address]{ [StreetAddress] =>"Some Street" [StreetName] => "Some Name" } [Marks1] => 100 [Marks2] => 50 } Now I want to create database table like whic...