LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 695|回复: 3

类型强制转换有点问题

[复制链接]
发表于 2006-6-22 09:56:34 | 显示全部楼层 |阅读模式

  1. typedef unsinged long  u32

  2. const char* time = "1000000";
  3. u32 stationtime;

  4. stationtime = const_cast<u32* >time;
复制代码

转不过来,有其他方法吗?
发表于 2006-6-22 12:32:41 | 显示全部楼层
man strtol
man atol
回复 支持 反对

使用道具 举报

发表于 2006-6-22 13:50:40 | 显示全部楼层
man strtoul
回复 支持 反对

使用道具 举报

发表于 2006-6-22 14:12:27 | 显示全部楼层
这么多天了,怎么还问这么初级的cpp问题?
有两个办法:
1. 用传统 c 的方法: stationtime = (u32)time;
2. 用 cpp 方式: stationtime = reinterpret_cast<u32>(time);

btw: 还是那句话,有没有看过一本 cpp 的书?
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表