Archived
1
0
Fork 0

Prototype which initializes Tox and prints address

This commit is contained in:
Braiden Vasco 2015-07-25 20:52:40 +05:00
parent 6798f06310
commit c3298d2f66

29
main.c
View file

@ -1,4 +1,33 @@
#include <tox/tox.h>
#include <stdio.h>
#include <string.h>
int main() int main()
{ {
struct Tox_Options tox_options;
memset(&tox_options, 0, sizeof(struct Tox_Options));
tox_options_default(&tox_options);
TOX_ERR_NEW err;
Tox *tox = tox_new(&tox_options, &err);
if (err != TOX_ERR_NEW_OK)
exit(EXIT_FAILURE);
char address[TOX_ADDRESS_SIZE];
tox_self_get_address(tox, (uint8_t*)address);
printf("ID: ");
for (int i = 0; i < TOX_ADDRESS_SIZE; ++i) {
char d[3];
snprintf(d, sizeof(d), "%02X", address[i] & 0xFF);
printf("%s", d);
}
printf("\n");
return 0; return 0;
} }