原文地址:http://blog.csdn.net/sunlion81/article/details/8838159
-
#include
-
#include
-
#include // for pj_init.
-
-
#define THIS_FILE "main.c"
-
-
-
-
-
void array_test(void);
-
-
static pj_status_t matching_cb(const void *value);
-
-
int main(int argc, char** argv)
-
{
-
pj_status_t status;
-
-
-
status = pj_init();
-
if (status != PJ_SUCCESS)
-
{
-
char errmsg[PJ_ERR_MSG_SIZE];
-
pj_strerror(status, errmsg, sizeof(errmsg));
-
PJ_LOG(1,(THIS_FILE, "%s: %s [status=%d]", pj_init, errmsg, status));
-
return -1;
-
}
-
-
-
array_test();
-
-
-
pj_shutdown();
-
-
return 0;
-
}
-
-
-
-
-
void array_test(void)
-
{
-
char a = '@';
-
char* p = NULL;
-
char array[32] = "abc123";
-
-
PJ_LOG(3, (THIS_FILE, "array = %s", array));
-
-
-
pj_array_insert(array, sizeof(char), (unsigned)strlen(array), 3, &a);
-
PJ_LOG(3, (THIS_FILE, "array = %s", array));
-
-
-
pj_array_erase(array, sizeof(char), (unsigned)strlen(array), 3);
-
array[strlen(array)-1] = '\0';
-
PJ_LOG(3, (THIS_FILE, "array = %s", array));
-
-
-
pj_array_find(array, sizeof(char), (unsigned)strlen(array), matching_cb, &p);
-
}
-
-
static pj_status_t matching_cb(const void *value)
-
{
-
char *p = (char*)value;
-
-
PJ_LOG(3, (THIS_FILE, "*p = %s", p));
-
-
-
-
return PJ_SUCCESS;
-
}
阅读(738) | 评论(0) | 转发(0) |