I'm using Java NDK in order to extract some info from a "bin" file using a C struct. I have to extract info about a gateway, in for loop. I'm able to extract info, but I need to concatenate the results and add dot .
in order to print the final IP and convert it to char*
or string
.
I used reinterpret_cast
but it doesn't work.
How can I convert the IP address to a string?
#define LOGD(...) __android_log_print(ANDROID_LOG_DEBUG, LOG_TAG, __VA_ARGS__)
//Gateway.info[4] is unsigned char type
int config_len = sizeof(ptr->Gateway.info);
for (int i = 0; i < config_len; i++) {
int number = ptr->Gateway.info[i];
}
LOGD("GATEWAY %d",number);
I made a mistake. It works!
#define LOGD(...) __android_log_print(ANDROID_LOG_DEBUG, LOG_TAG, __VA_ARGS__)
string Result;
ostringstream convert;
//Gateway.info[4] is unsigned char type
int config_len = sizeof(ptr->Gateway.info);
for (int i = 0; i < config_len; i++) {
int number = ptr->Gateway.info[i];
convert << number;
Result = convert.str()
}