#include #include "Prompt.h" JNIEXPORT jstring JNICALL Java_Prompt_getLine(JNIEnv *env, jobject obj, jstring prompt, jint i) { char buf[128]; const jbyte *str; str = (*env)->GetStringUTFChars(env, prompt, NULL); if (str == NULL) { return NULL; /* OutOfMemoryError already thrown */ } printf("Number:%d, %s", i, str); (*env)->ReleaseStringUTFChars(env, prompt, str); /* We assume here that the user does not type more than * 127 characters */ /* gets(buf); 2015, I changed it to the next line because no check for buffer overrun is performed. */ fgets(buf, 128, stdin); return (*env)->NewStringUTF(env, buf); }