========================================================== =============================== Original blog, reprinted please declare the source of Electronic coffee (original id blue rock) ========================================================== ================================
Conversion between JNI jstring and char *
/+++++++++++++++++++++++++//jstring to char*//NOTICE: you need free return value,like free(ch)char* jstringToChar(JNIEnv* env, jstring jstr){char* rtn = NULL;jclass clsstring =
codedigits)
{
// Algorithm
Csm3otp * sm3otp = new csm3otp;
Sm3otp-> hotpwithkey ("e65c3167cb8d9c79747b8e21c82aebec", "000000005034b136", 8 );
Return atoi (sm3otp-> computepassword ());
}
4. This error is a Data Type Mismatch Error.
Remember to convert the data type, including the conversion between jstring and jbyte
--------------------------------------
The conversion of several data types was correct.CodeLeft:
/////////////// // // Jstring to char * Char * J
1 The interface for defining a C method is equivalent to the implementation of an interface interface defined in Java code that is implemented by the C languagepublic native int login (String password);2 Implementing C codeIn the directory of the Android project under SRC, you can use the command: (javah-jni full-class name) to generate a corresponding C-language function header file#include #include "Com_qushaohui_aliwangwang_mainactivity.h"int login (char* psw) {char* rightpwd = "123";if (strc
); Query OK, 0 rows affected (0.27 sec)
// Insert several data entries into the user tableMysql> insert into user values ('Tom ', '123 ');Query OK, 1 row affected (0.05 sec)
Mysql> insert into user values ('alen', '123 ');Query OK, 1 row affected (0.08 sec)
Mysql> insert into user values ('jack', '123 ');Query OK, 1 row affected (0.04 sec)
// View the data in the user tableMysql> select * from user;+ ------ + ---------- +| Name | password |+ ------ +
This article then implements the "Android Java pass int type data to C" method is still not implemented:Public native string Sayhelloinc (string s);First put a tool method, the specific meaning of the following article will be introduced/** * Convert a jstring to a C language char* type.*/Char* _JSTRING2CSTR (jnienv*env, jstring jstr) { Char* Rtn =NULL; Jclass clsstring= (*env)->findclass (env,"java/lang/string"); Jstring Strencode= (*env)->newstringutf (env,"GB2312"); Jmethodid Mid= (*env)->
= first.length;
For (t[] array:rest) {
System.arraycopy (Array, 0, result, offset, array.length);
Offset + = Array.Length;
}
return result;
}
public static Use the following:String[] both = concat(first, second);String[] more = concat(first, second, third, fourth);Iv. array.newinstanceYou can also use Array.newInstance to generate an array:[Java]View Plaincopyprint?
Private static
final int alen = a.length;
final int blen =
table below the test library empty Set (0.00 sec)//Create a user table, name and password two fields mysql> create table user (name VARCHAR, password VAR CHAR (20)); Query OK, 0 rows affected (0.27 sec)//inserts several data into the user table mysql> insert into user values (' Tom ', ' 1321 '); Query OK, 1 row affected (0.05 sec) mysql> insert into user values (' Alen ', ' 7875 '); Query OK, 1 row affected (0.08 sec) mysql> insert into user values
Makefile:All:gcc-o Server Server.c-lpthreadgcc-o Client CLIENT.CCLEAN:RM Server ClientSERVER.C:/*tcp:server.c*/#include/*See NOTES*/#include#includeinch.h>#include#include#include#include#includestring.h>#includevoid*do_work (void*Arg);intMainintargcChar*argv[]) { intSOCKFD; intret; /*1. Call the socket to establish a network socket*/SOCKFD= Socket (Af_inet,sock_stream,0); if(-1==sockfd) {Perror ("Socket Server"); return-1; } /*2. Populating the server address and port number*/ structso
DescriptionGive two positive integers a and B to calculate the value of a-a. Ensure that the number of digits A and B does not exceed 500 digits.InputRead in two positive integers separated by a spaceOutputOutput A-B valueSample Input3 12Sample Output-9HintThe number of digits of two positive integers is less than 500 bits#include #include#includeusing namespacestd;Charsa[510],sb[510];inta[510],b[510];intMain () {CIN>>Sa>>Sb; intAlen=strlen (Sa), blen=strlen (SB); intL=Max (
Reference: http://blog.csdn.net/andyxie407/article/details/1672325
Today, I encountered a lot of problems running on the 16-14 (client) and 16-15 (server) In chapter 16th of apue, run the method thanks to the andyxie407 article for a good reference (originally the same, not for reference), but still cannot run the results, the results found the wrong place of the two programs (forgive me, sometimes, I think the code will be knocked out at a glance.) I write it all here, and I will show the painf
encoding can end with two "=" at most"Decoding base64 is just a simple inverse process of encoding. You can discuss it yourself. I will give the decoding algorithm at the end of the article.
For more information, see rfc2045, rfc2046, and "Fantastic base64 encoding". Luo Cong and other materials from the Internet
Algorithm Implementation (independently implemented)
# Include # Include Char encodetab [] = "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz0123456789 +/= ";Char decodetab [124]
array:void Tournamet (int a[],int len,int *max,int *secondmax) {int aLen = 2*len;int *ta = (int*) malloc (sizeof (int) *alen); int i;in T secondlarge = -1;for (i=len;i2): Using a tournament algorithm with an additional space of N, this algorithm directly uses the original array as the leaf node of the heap, in the process of searching if the size of the extra array is searched from the original array, the
First type:
Copy Code code as follows:
/** 's * *
function merge (A, b) {
var aLen = A.length,
Blen = B.length,
MaxLen = Math.max (ALen, Blen),
Sumlen = ALen + Blen,
result = [],
AP = 0,
bp = 0;
while (Result.length if (AP if (A[ap] > B[BP]) {Result.push (b[bp++]);} else {Result.push (a[ap++]);}Or else if (! AP while (BP Result.push (b[bp++
This article introduces the sample code for js3 merge operations. If you need it, refer to the first one:
The Code is as follows:
/** Liang GE's */Function merge (a, B ){Var aLen = a. length,BLen = B. length,MaxLen = Math. max (aLen, bLen ),SumLen = aLen + bLen,Result = [],Ap = 0,Bp = 0;
While (result. length If (ap If (a [ap]> B [bp]) {Result. push (B [bp ++])
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.