C艺术
时间:2010-05-13 来源:binghuiliang
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);
相关阅读 更多 +