CSDN首页 空间 新闻 论坛 Blog 下载 读书 网摘 搜索 .NET Java 视频 接项目 求职 在线学习 买书 程序员 通知
山寨机中的战斗机! 程序优化工程师到底对IT界有没有贡献
CSDN社区
搜索 收藏 打印 关闭
CSDN社区 >  C/C++ >  C语言

在线请教:如何将(__int64)类型的变量转换成string类型(Visual C++6.0)

楼主ailanrenxfl(凌风行)2003-05-02 18:19:29 在 C/C++ / C语言 提问

如题  
   
  多谢! 问题点数:50、回复次数:9Top

1 楼pengzhenwanli(紫气日盈)回复于 2003-05-02 19:20:49 得分 2

#include   <sstream>  
  using   namespace   std;  
   
  stringstream   sstr;  
  __int64   a;  
   
  sstr   <<   a;  
  string   str   =   sstr.str();Top

2 楼ailanrenxfl(凌风行)回复于 2003-05-02 21:01:18 得分 0

不行啊!  
   
  error   C2593:   'operator   <<'   is   ambiguous  
   
  Top

3 楼ailanrenxfl(凌风行)回复于 2003-05-02 21:13:20 得分 0

怪事!  
  我发现int   \   unsigned   long这样做都可以  
  就是__int64   的时候回报上面的错误Top

4 楼luhongxu(Jackie)回复于 2003-05-03 08:48:43 得分 2

大哥,   用sprintf函数!Top

5 楼swotcoder(苦 丁 www.help2u.org)回复于 2003-05-03 09:10:28 得分 2

__int64   在32位机器上连用都不能用说。Top

6 楼xzygod(急风知劲草)回复于 2003-05-03 10:19:01 得分 2

分2次转,高32位和低32位,然后连接起来Top

7 楼snipersu()回复于 2003-05-03 10:37:27 得分 0

看看msdn  
  #include<stdlib.h>  
  char   *_i64toa(   __int64   value,   char   *string,   int   radix   );Top

8 楼snipersu()回复于 2003-05-03 10:40:12 得分 0

#include<cstdlib>  
  #include<iostream>  
  #include   <string>  
  using   namespace   std;  
  void   main()  
  {  
  __int64   a=1234567890987654321;  
  char   buffer[32];  
  string   str(_i64toa(a,buffer,10));  
  cout<<_i64toa(a,buffer,10)<<endl;  
  cout<<str<<endl;  
  }  
  Top

9 楼snipersu()回复于 2003-05-03 10:43:38 得分 42

如果你没有msdn的话看看这个(copy   from   msdn)  
  _itoa,   _i64toa,   _ui64toa,   _itow,   _i64tow,   _ui64tow  
  Convert   an   integer   to   a   string.  
   
  char   *_itoa(   int   value,   char   *string,   int   radix   );  
   
  char   *_i64toa(   __int64   value,   char   *string,   int   radix   );  
   
  char   *   _ui64toa(   unsigned   _int64   value,   char   *string,   int   radix   );  
   
  wchar_t   *   _itow(   int   value,   wchar_t   *string,   int   radix   );  
   
  wchar_t   *   _i64tow(   __int64   value,   wchar_t   *string,   int   radix   );  
   
  wchar_t   *   _ui64tow(   unsigned   __int64   value,   wchar_t   *string,   int   radix   );  
   
  Routine   Required   Header   Compatibility    
  _itoa   <stdlib.h>   Win   95,   Win   NT    
  _i64toa   <stdlib.h>   Win   95,   Win   NT    
  _ui64toa   <stdlib.h>   Win   95,   Win   NT    
  _itow   <stdlib.h>   Win   95,   Win   NT    
  _i64tow   <stdlib.h>   Win   95,   Win   NT    
  _ui64tow   <stdlib.h>   Win   95,   Win   NT    
   
   
  For   additional   compatibility   information,   see   Compatibility   in   the   Introduction.  
   
  Libraries  
   
  LIBC.LIB   Single   thread   static   library,   retail   version    
  LIBCMT.LIB   Multithread   static   library,   retail   version    
  MSVCRT.LIB   Import   library   for   MSVCRT.DLL,   retail   version    
   
   
  Return   Value  
   
  Each   of   these   functions   returns   a   pointer   to   string.   There   is   no   error   return.  
   
  Parameters  
   
  value  
   
  Number   to   be   converted  
   
  string  
   
  String   result  
   
  radix  
   
  Base   of   value;   must   be   in   the   range   2   –   36  
   
  Remarks  
   
  The   _itoa,   _i64toa,   and   _ui64toa   function   convert   the   digits   of   the   given   value   argument   to   a   null-terminated   character   string   and   stores   the   result   (up   to   33   bytes)   in   string.   If   radix   equals   10   and   value   is   negative,   the   first   character   of   the   stored   string   is   the   minus   sign   (   –   ).   _itow,   _i64tow,   and   _ui64tow   are   wide-character   versions   of   _itoa,   _i64toa,   and   _ui64toa   respectively.  
  Top

相关问题

  • c++/vc中如何将int型的变量链接到string型的变量上
  • visual c++.net里面怎么添加成员变量
  • 如何将string类型的变量转换成int型的变量?ASP.NET(C#)马上给分!
  • C++中 如何将string类型(不是char*)的变量转换成int和float???
  • 请问,如何去掉string 类型变量中的空格(c#),肯定给分!!!
  • 请问如何去掉string类型变量中的空格(c#),肯定给分!!!
  • 请问在c#中如何将string类型的变量转换为int型的!
  • c++中变量类型
  • 如何将C++中的string转变成char,我要将char变量与string中的字母作比较?
  • 在标准C++中使用STL string变量,如果不调用~basic_string(),会造成内存泄漏吗?

关键词

  • nt
  • toa
  • tow
  • win
  • ui
  • retail versions
  • character
  • library
  • lib
  • include

得分解答快速导航

  • 帖主:ailanrenxfl
  • pengzhenwanli
  • luhongxu
  • swotcoder
  • xzygod
  • snipersu

相关链接

  • C/C++ Blog
  • C/C++类图书
  • C/C++类源码下载

广告也精彩

反馈

请通过下述方式给我们反馈
反馈
提问
网站简介|广告服务|VIP资费标准|银行汇款帐号|网站地图|帮助|联系方式|诚聘英才|English|问题报告
北京创新乐知广告有限公司 版权所有, 京 ICP 证 070598 号
世纪乐知(北京)网络技术有限公司 提供技术支持
Copyright © 2000-2008, CSDN.NET, All Rights Reserved
GongshangLogo