Chinaunix首页 | 论坛 | 博客
  • 博客访问: 290148
  • 博文数量: 34
  • 博客积分: 1400
  • 博客等级: 上尉
  • 技术积分: 433
  • 用 户 组: 普通用户
  • 注册时间: 2008-07-23 13:16
文章分类

全部博文(34)

文章存档

2011年(3)

2010年(4)

2009年(6)

2008年(21)

我的朋友

分类: 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);

 

阅读(1350) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~