本文共 1003 字,大约阅读时间需要 3 分钟。
从昨晚困扰我到现在的问题,终于解决了~~~
先贴源程序
testpcre.c
#include#include #include int main(int argc, char ** argv){ if (argc != 3) { printf("Usage: %s pattern text\n", argv[0]); return 1; } const char * pPattern = argv[1]; const char * pText = argv[2]; const char * pErrMsg = NULL; pcre * pPcre = NULL; int nOffset = -1; if (NULL == (pPcre = pcre_compile(pPattern, 0, &pErrMsg, &nOffset, NULL))) { printf("ErrMsg=%s, Offset=%d\n", pErrMsg, nOffset); return 1; } else { if (pcre_exec(pPcre, NULL, pText, strlen(pText), 0, 0, NULL, 0) < 0) { printf("%s doesn't match %s\n", pText, pPattern); } else { printf("%s matches %s\n", pText, pPattern); } }}
昨晚已经下载好pcre了
可是一运行还是会报错
查了半天才知道运行的时候要在命令行链接上 : -lpcre
gcc -o testpcre testpcre.c -lpcre
然后就可以了!!!
转载地址:http://jcssi.baihongyu.com/