#include
#include
#include
#include
void str2pixel(void *string, char delim, void *width, void *height)
{
char *path=strdup(string);
char *pname;
char *pt,*pp,*pf;
pname = rindex(path, '/');
if (pname == NULL)
pname = path;
else ++pname;
pt = strchr(pname, delim);
if (pt) {
*pt = 0;
pp = pt - 1;
while (isdigit(pp[-1])) --pp;
pf = pt + 1;
while (isdigit(pf[0])) ++pf;
*pf = 0;
pf = pt + 1;
if (!(pp && pf)) {
pp = pf = "";
}
} else {
pp = pf = "";
}
if (width) strcpy(width, pp);
if (height) strcpy(height, pf);
free(path);
}
int main(void)
{
char *path="/vobs/123/abc_800x600slasd.bmp";
char width[64];
char height[64];
str2pixel(path, 'x', width, height);
printf("0x%02x - %s\n", width[0], width);
printf("0x%02x - %s\n", height[0], height);
}
阅读(1518) | 评论(1) | 转发(0) |