如何使用regexp来进行正则表达式的匹配?
如何使用regexp来进行正则表达式的匹配?
下面这个程序有何不妥,请各位打下指正:
#define INIT register char *sp=instring;
#define GETC() (*sp++)
#define PEEKC() (*sp)
#define UNGETC(c) (--sp)
#define RETURN(c) return;
#define ERROR(c) regerr()
#include <stdio.h>
#include <regexp.h>
main()
{
char expbuf[10];
char linebuf[80];
strcpy(expbuf,"^[0-9]*$");
compile((char *)0,expbuf,&expbuf[sizeof(expbuf)],'\0');
for (;;)
{
printf("please input a string:\n");
scanf("%s\n",linebuf);
if (step(linebuf,expbuf))
{
printf("success!\n");
}
else
printf("failed!\n");
}
}
编译时提示regerr未定义,不知何故?希望各位大虾能以例程解答
请发email至bone_dragon@21cn.com,多谢!