I'm normally programming in c++, but are using some clibrary functions for my char*.
Some of the manpages like for 'getline', says that input should be a malloced array.
Is it ok, to use 'new' instead?
I can see for my small sample that it works, but could this at some point result in some strange undefined behavior?
I know that a 'n...
Hi there,
If someone could assist me please. I'm doing a jquery Ajax post, for some reason the Json object isn't working so just returning a php array instead
$.post
(
"classes/RegisterUser.php",
$("#frmRegistration").serialize(),
function(data)
{
alert(data);
}
);
The data is returned to Javascript 100% as
...
Hi,
Here in an array i have in javascript, this works great!
_rowData: [
{ name: "Most Recent", view: "recentView" },
{ name: "Most Popular", view: "popularView" },
{ name: "Staff Picks", view: "staffView" }
],
How could i generate this array from a php script? I want to use AJAX to get the results returned by the php.
...
Hi all,
Is there a way to sort an array using Chrome?
Using the sort function does not work as seen in this example:
var myArray = [1,4,5,3,2];
myArray.sort ( function( a , b ){
return b>a
});
for ( var i = 0; i < myArray.length; i++ )
{
document.write( myArray[i] )
}
Firefox / IE / Opera / Safri output: 54321
Chrome output...
I'd like to print out all prime numbers from an array with method. I can do it with one int
but don't know how to return certain numbers from array. Thanks for help!
public static boolean isPrime(int [] tab) {
boolean prime = true;
for (int i = 3; i <= Math.sqrt(tab[i]); i += 2)
if (tab[i] % i == 0) {
...
I've successfully created an item scanner for my game.
Here is my code:
import java.io.*;
import java.util.*;
public class ItemScanner {
public static void main(String args[]) {
System.out.print("Enter item to find: ");
Scanner sc = new Scanner(System.in);
find(sc.nextLine());
}
public static v...
A follow up to my Item Scanner, a java tool that scans through a directory of *.txt files.
Thank you all for the help! However now I have a different problem.
When I get the results it reads strings I do not want it to read. How can I block out these strings I do not want it reading?
This is an example what I mean:
Enter item to fin...
So I have something like this
#define HASHSIZE 1010081
static struct nlist *hashtab[HASHSIZE];
Now I want to be able to change the HASHSIZE of my hashtab, because I want to test different primes numbers and see which would give me less collisions. But Arrays do not take variable sizes so HASHSIZE has to be a constant. Is there a way ...
hi i have the following c code
int *a;
size_t size = 2000*sizeof(int);
a = (int *) malloc(size);
which works fine... but now if i have the following
char **b = malloc(2000*sizeof *b);
where every element of b has different length...
now, how is it possible to do the same thing for b as i did for a, i.e. is the below c...
I have a System.Array that I need to convert to string[]. Is there a better way to do this than just looping through the array, calling ToString on each element, and saving to a string[]? The problem is I don't necessarily know the type of the elements until runtime.
...
Hi,
I am trying to create a single array that contains all of the values of an existing multidimensional array. This is what I have so far...
function MaxArray($arr) {
foreach ($arr as $value) {
if (is_array($value)) {
MaxArray($value);
} else {
$array[] = $value;
}
}
print...
hi i have the following code...
int *a, *b;
int *d;
int N = 2000;
size_t size = N*sizeof(int);
a = (int *) malloc(size);
b = (int *) malloc(size);
...
cudaMalloc((void **) &d, size);
it works just fine... now assume i have the following
char **t = malloc(2000* sizeof *t);
for(...)
{
...
t[i] = (char *)mal...
Hi,
i defined boost::multi_array with
typedef boost::multi_array<unsigned int, 1> uint_1d_vec_t;
typedef boost::multi_array<unsigned int, 2> uint_2d_vec_t;
uint_1d_vec_t foo( boost::extents[ num_elements ] );
uint_2d_vec_t boo( boost::extents[ num_elements/2 ][ kappa ] );
were num_elements/2 ist an integer number...
Hello!
There is the function GetLinksFromPage. She have created a links array, then I wanna pass that array to COM-object (only URLs), thus I have to convert CAtlArray< CComPtr< IDispatch> > to CComSafeArray< BSTR>. How I can do it ?
HRESULT myclass::GetLinksFromPage( const CComPtr<IHTMLDocument2>& pDoc, CAtlArray<CComPtr<IDispatch> > &...
Hi
While using method Arrays.deepToString(Object [] a) I am facing this problem which I can put down in this way.
Object [] not_allowed = new int[]{7, 9, 8};
Object [] allowed = new int[][]{{1, 2, 3}, {6, 5, 4}};
Why i am not allowed to assign int[] to Object[] in single dimension case but i am allowed to do such in multidimensio...
My JavaScript code stores a lot of data in arrays. I want to retrieve a key using something similar to what I wrote below. It key that should be retrieved is based on variables that are page-dependent . The following code doesn't work. Can anyone give me a solution to this problem?
This is part of a script that does automatic conjugatio...
Hi,
I have an array of 16 squares and I would like to auto complete it with integers values depending of the position in the array and the vector TOP_RIGHT.
TOP_RIGHT = 3
# Build the array...
@top_right = Array.new(16, 0)
@top_right.each_index do |square|
@top_right[square] = square / TOP_RIGHT if (0...16).include?(square - TOP_RIGH...
Hi all,
C# newbie working off some tutorials. Is there a way to run an identical command on every object in an array?
Here is my current (working) code:
Guys[0].Cash += Guys[0].MyGuess.PayOut(WinnerNumber);
Guys[1].Cash += Guys[1].MyGuess.PayOut(WinnerNumber);
Guys[2].Cash += Guys[2].MyGuess.PayOut(WinnerNumber);
I...
Hi all..
In C, i have read tat half-initialized arrays will be filled with zeros for the rest of the elements (irrespective of integer or char arrays)..
Eg: int arr[10] = {3};
arr[4] will be 0 if initialized and a junk value if not initialized
My question is, will the above work for all C compilers (or) this appending of zeros mi...
Hi,
i despair in case of an array.
I put some data into an array, but when i iterate the array some
elements of the array seems to be missed, but the missing element are
displayed in the view.
I'm using the Plugin Rails_Authorization.
my Code:
def index
if !params[:task_id] #Tasks der 1. ebene anzeigen, auf die der User zugr...