char *a[]={"diamonds","clubs","spades","hearts"};
char **p[]={a+3,a+2,a+1,a};
char ***ptr=p;
cout<<*ptr[2][2];
why does it display h and please explain how is the 2d array of ptr implementing and its elements
In Javascript, after executing a function I can immediately get the an element of the array returned by the function, like so:
myFunc("birds")[0] //gets element zero returned from "myFunc()"
This is much easier and faster than doing this:
$myArray = myFunc("birds");
echo $myArray[0];
Does PHP have a similar shorthand to javascript? I'm just curious. Thanks in advance!
Hi I would like to ask if its possible get array with clear data from ActiveRecord query without using map, collect or each.
names = User.find(:all, :select => "name")
return names == [#<User name:"Peter">,#<User name:"Martin">]
and I want names == ["Peter", "Martin"] without using map, collect or each. Thanks for your answers.
Hi everyone,
I am really not sure if this is the right way to go, since exceptions is really a fresh subject to me. Is it possible to catch multiple exceptions (let the execution of the script continue) and then store the exceptions in a array to be able to return all exceptions caused?
By that said, it would be awesome to be able to use exceptions to more than just showing an error that kills the application (script)
Thanks!
i have a java method that is part of an web service interface and that takes a byte array parameter like this
public int computeSomeThind(byte[] data) {
if(data != null) {
// ... do what ever
} else {
return -1;
}
}
When a generate the wsdl with axis 1.3 the data parameter will appear as not nullable. Is there a way to define this as nullable?
If I have the following plain string, how do I divide it into an array of three elements?
{["a","English"],["b","US"],["c","Chinese"]}
["a","English"],["b","US"],["c","Chinese"]
This problem is related to JSON string parsing, so I wonder if there is any API to faciliate the conversion.
What is the preffered method for creating a byte array from an input stream?
Here is my current solution with .NET 3.5.
Is it still a better idea to read and write chunks of the stream?
Stream s;
byte[] b;
using (BinaryReader br = new BinaryReader(s)) {
b = br.ReadBytes(s.Length);
}
Does anyone know there have any other way that (by not using json_encode and json_decode) to encode an array into string then decode it back into string? I remember there have another call unlis...(cannot really remember the name :( )
I have a two dimensional JSON array where each element contains several attributes. The example below is intentionally simplified:
var map_data = { "1":
{"1":{"name":"aa"},"2":{"name":"bb"}},
"2":
{"1":{"name":"cc"},"2":{"name":"dd"}}
};
I try to parse the data but .length doesn't work:
for(x=1; x<=map_data.length; x++) {
for(y=1; y<=map_data[x].length; y++) {
// CODE
}
}
Many, many thanks!
I want to turn a screen shot from the clipboard into a array data (Red/Green/Blue) in my program. so i guess it's as simple as that. but i don't want to use anything else then the print screen and clipboard if i can?
anyway any questions just ask.
Hello all, I just wanted to know what is the main advantage of using the iterators over the array indices. I have googled but i am not getting the right answer.
I have the below configuration where I'm trying to create a test C function that returns a pointer to an Array of Strings and then wrap that using SWIG's carrays.i and array_functions so that I can access the Array elements in Java.
Uncertainties:
%array_functions(char, SWIGArrayUtility); - not sure if char is correct
inline char *getCharArray() - not sure if C function signature is correct
String result = getCharArray(); - String return seems odd, but that's what is generated by SWIG
SWIG.i:
%module Test
%{
#include "test.h"
%}
%include <carrays.i>
%array_functions(char, SWIGArrayUtility);
%include "test.h"
%pragma(java) modulecode=%{
public static char[] getCharArrayImpl() {
final int num = numFoo();
char ret[] = new char[num];
String result = getCharArray();
for (int i = 0; i < num; ++i) {
ret[i] = SWIGArrayUtility_getitem(result, i);
}
return ret;
}
%}
Inline Header C Function:
#ifndef TEST_H
#define TEST_H
inline static unsigned short numFoo() {
return 3;
}
inline char *getCharArray(){
static char* foo[3];
foo[0]="ABC";
foo[1]="5CDE";
foo[2]="EEE6";
return foo;
}
#endif
Java Main Tester:
public class TestMain {
public static void main(String[] args) {
System.loadLibrary("TestJni");
char[] test = Test.getCharArrayImpl();
System.out.println("length=" + test.length);
for(int i=0; i < test.length; i++){
System.out.println(test[i]);
}
}
}
Java Main Tester Output:
length=3
?
?
,
SWIG Generated Java APIs:
public class Test {
public static String new_SWIGArrayUtility(int nelements) {
return TestJNI.new_SWIGArrayUtility(nelements);
}
public static void delete_SWIGArrayUtility(String ary) {
TestJNI.delete_SWIGArrayUtility(ary);
}
public static char SWIGArrayUtility_getitem(String ary, int index) {
return TestJNI.SWIGArrayUtility_getitem(ary, index);
}
public static void SWIGArrayUtility_setitem(String ary, int index, char value) {
TestJNI.SWIGArrayUtility_setitem(ary, index, value);
}
public static int numFoo() {
return TestJNI.numFoo();
}
public static String getCharArray() {
return TestJNI.getCharArray();
}
public static char[] getCharArrayImpl() {
final int num = numFoo();
char ret[] = new char[num];
String result = getCharArray();
System.out.println("result=" + result);
for (int i = 0; i < num; ++i) {
ret[i] = SWIGArrayUtility_getitem(result, i);
System.out.println("ret[" + i + "]=" + ret[i]);
}
return ret;
}
}
Func archiveDir($dir)
; Get all the files under the current dir
$allOfDir = _FileListToArray($dir)
Local $countDirs = 0
Local $countFiles = 0
$imax = UBound($allOfDir)
For $i = 0 to $imax - 1
If StringInStr(FileGetAttrib($allOfDir[$i]),"D") Then
$countDirs = $countDirs + 1
Else
$countFiles = $countFiles + 1
EndIf
Next
Local $allDirs[$countDirs]
Local $allFiles[$countFiles]
The error text is : "Array variable subscript badly formatted." and comes on this line:
Local $allDirs[$countDirs]
Any ideas?
You have been given an array of size 2n+1 that have n pair of integers(can be +ve, -ve or 0) and one unpaired element.
How would you find the unpaired element.
Pair means duplicate. So (3,3) is a pair and (3,-3) is not a pair.
Hello experts,
How can I convert a PSID type into a byte array that contains the byte value of the SID?
Something like:
PSID pSid;
byte sidBytes[68];//Max. length of SID in bytes is 68
if(GetAccountSid(
NULL, // default lookup logic
AccountName,// account to obtain SID
&pSid // buffer to allocate to contain resultant SID
)
{
ConvertPSIDToByteArray(pSid, sidBytes);
}
--how should I write the function ConvertPSIDToByteArray?
Thank you!
Possible Duplicate:
Problem with jQuery array
$('div#pics>img')[0].show('slow');
where the html is having a bunch of child img tags inside div tag.
but the above posted jQuery line is not working .I was wondering why.:(
Hello.
I have an array with integers of values from 0 to 100. I wish to remove integers that are less than number X and keep the ones that are equal or greater than number X.
I am using PHP.
Thanks!
I have looked around for a simple answer to this and cannot seem to find on (you wouldn't think a simple thing would be hard!)
How do you sort an array of NSNumbers?
If I have a 2D array that is arranged as follows :
String X[][] = new String [][] {{"127.0.0.9", "60", "75000","UDP", "Good"},
{"127.0.0.8", "75", "75000","TCP", "Bad"},
{"127.0.0.9", "75", "70000","UDP", "Good"},
{"127.0.0.1", "", "70000","UDP", "Good"},
{"127.0.0.1", "75", "75000","TCP", "Bad"}
};
I want to know the frequency of each value .. so I27.0.0.9 gets 2. How can I do a general solution for this ? In Java or any algorithm for any language ?
Variable $d comes from file_get_contents function to a url.
$answer = @new SimpleXMLElement($d);
Below is output of the print_r($answer):
SimpleXMLElement Object
(
[Amount] = 2698
[Status] = OK
[State] = FL
[Country] = USA
)
How can I retrieve value of each element and add to an array? can't figure it out.
Can someone please give the Java equivalent of the below python (which slices a given array into given parts) which was originally written by ChristopheD here:
def split_list(alist, wanted_parts=1):
length = len(alist)
return [ alist[i*length // wanted_parts: (i+1)*length // wanted_parts]
for i in range(wanted_parts) ]
I don't know any python but can really use the above code in my Java app. Thanks
I currently have a MapToolKit.html , and two .js files namely map.js and search.js. When i search places like starbucks, they will return me addresses and coordinates stored into an array. I would like to display those multiple values into the html page, not just one value which i currently did it on my coding now.
Here's the source code:
http://www.mediafire.com/?0minqxgwzmx
I have a form with a collection of checkbox's for a refine search function on my website.
I am trying to pass an array in a form GET but the URL looks like:
/search?filter=foo&filter=bar&filter=green
Is there a better way to pass this in MVC? Possible like
/search?filter=foo,bar,green
Thanks in advance.
If I have the following plain string, how do I divide it into an array of three elements?
{["a","English"],["b","US"],["c","Chinese"]}
["a","English"],["b","US"],["c","Chinese"]
This problem is related to JSON string parsing, so I wonder if there is any API to facilitate the conversion.