概要
vistaでandroid studio 1.1.0やってみた。
jniやってみた。
練習問題やってみた。
練習問題
jniでzundokoを表示せよ。
写真
サンプルコード
#include <jni.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
JNIEXPORT jstring JNICALL Java_com_ohisamallc_ohiapp154_ohiapp154_MainActivity_hello(JNIEnv * env, jobject thiz) {
char buf[456];
const char * s0 = "ズン ";
const char * s1 = "ドコ ";
const char * s2 = "ドコ キヨシ!!";
int i = 0;
int n = 0;
while (i == 0)
{
if ((rand() & 1) > 0)
{
strcat(buf, s1);
n = 0;
}
else
{
strcat(buf, s0);
n++;
}
if (n == 4)
{
strcat(buf, s2);
break;
}
}
return (* env)->NewStringUTF(env, buf);
}
以上。