求个小程序

做或不做 2013-10-22 04:11:40
例如 0:15:24+1
这是个udp发过来的信号 已经存入数组
我需要有人帮我把它解析成
typedef struct get_time{
int wHour;
int wMinute;
int wSecond;
}*GET_TIME;
get_time info;

info.wHour = 0
info.wMinute = 15
info.wSecond = 25

command = 1

我要写的东西太多了 没空写了 谁有空帮个忙 今天就玩CSDN了 工作都没搞定呢
...全文
201 4 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
做或不做 2013-10-22
  • 打赏
  • 举报
回复
引用 1 楼 stereoMatching 的回复:

int hour, min, sec, command;
    sscanf(strs.c_str(), "%d:%d:%d+%d", &info.wHour, &info.wMinute, &info.wSecond, &command);
太简单了 我怎么没想到这么写 2分钟就搞定了
stereoMatching 2013-10-22
  • 打赏
  • 举报
回复

char const *strs = "0:15:24+1";
sscanf(strs, "%d:%d:%d+%d", &info.wHour, &info.wMinute, &info.wSecond, &command);
忘了删除多余的代码 想要更快的速度可考虑boost::spirit
Aist-memory 2013-10-22
  • 打赏
  • 举报
回复
char数组转CString再取子串
stereoMatching 2013-10-22
  • 打赏
  • 举报
回复

int hour, min, sec, command;
    sscanf(strs.c_str(), "%d:%d:%d+%d", &info.wHour, &info.wMinute, &info.wSecond, &command);

70,023

社区成员

发帖
与我相关
我的任务
社区描述
C语言相关问题讨论
社区管理员
  • C语言
  • 花神庙码农
  • 架构师李肯
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧