分类: C/C++
2010-05-13 00:26:40
1. snprintf
const size_t length = snprintf (NULL, 0, "%s%s", AGENT_DIR, AGENT_NAME);
char *agent_path = malloc (sizeof (char) * (length + 1));
sprintf (agent_path, "%s%s", AGENT_DIR, AGENT_NAME);
2. sscanf
int age = -1;
char *strPtr = "steven:18years";
scannf(strPtr, "%*s%d%*s", &age);