文档下载 文档下载导航
设为首页 | 加入收藏
搜索 请输入内容:  
 导航当前位置: 文档下载 > 所有分类 > IT/计算机 > 计算机软件及应用 > 常用数据类型转换
侵权投诉

常用数据类型转换

常用数据类型转化及操作

1.1 数学类型变量与字符串相互转换(这些函数都在STDLIB.H里)

(1)将数学类型转换为字符串可以用以下一些函数:

举例: _CRTIMP char * __cdecl _itoa(int, char *, int);//这是一个将数字转换为一个字符串类型的函数,最后一个int表示转换的进制

如以下程序:

int iTyep=3;

char *szChar;

itoa(iType,szChar,2);

cout<<szChar;//输出为1010

类似函数列表:

_CRTIMP char * __cdecl _itoa(int, char *, int);//为了完整性,也列在其中

_CRTIMP char * __cdecl _ultoa(unsigned long, char *, int);

_CRTIMP char * __cdecl _ltoa(long, char *, int);

_CRTIMP char * __cdecl _i64toa(__int64, char *, int);

_CRTIMP char * __cdecl _ui64toa(unsigned __int64, char *, int);

_CRTIMP wchar_t * __cdecl _i64tow(__int64, wchar_t *, int);

_CRTIMP wchar_t * __cdecl _ui64tow(unsigned __int64, wchar_t *, int);

_CRTIMP wchar_t * __cdecl _itow (int, wchar_t *, int);//转换为长字符串类型 _CRTIMP wchar_t * __cdecl _ltow (long, wchar_t *, int);

_CRTIMP wchar_t * __cdecl _ultow (unsigned long, wchar_t *, int);

还有很多,请自行研究

(2)将字符串类型转换为数学类型变量可以用以下一些函数:

举例: _CRTIMP int __cdecl atoi(const char *);//参数一看就很明了

char *szChar=”88”;

int temp(0);

temp=atoi(szChar);

cout<<temp;

类似的函数列表:

_CRTIMP int __cdecl atoi(const char *);

_CRTIMP double __cdecl atof(const char *);

_CRTIMP long __cdecl atol(const char *);

_CRTIMP long double __cdecl _atold(const char *);

_CRTIMP __int64 __cdecl _atoi64(const char *);

_CRTIMP double __cdecl strtod(const char *, char **);//

_CRTIMP long __cdecl strtol(const char *, char **, int);//

_CRTIMP long double __cdecl _strtold(const char *, char **);

_CRTIMP unsigned long __cdecl strtoul(const char *, char **, int);

_CRTIMP double __cdecl wcstod(const wchar_t *, wchar_t **);//长字符串类型转换为数学类型

_CRTIMP long __cdecl wcstol(const wchar_t *, wchar_t **, int);

_CRTIMP unsigned long __cdecl wcstoul(const wchar_t *, wchar_t **, int);

_CRTIMP int __cdecl _wtoi(const wchar_t *);

第1页

你可能喜欢

热门文档

相关文档

  • 常用数据类型转换

    常用数据类型转换_计算机软件及应用_IT/计算机_专业资料。一、其它数据类型转换为字符串 短整型(int) itoa(i,temp,10); //将i转换为字符串放入temp中,最后一...

  • 常用数据类型转换使用详解

    VC 常用数据类型使用转换详解 CString ,BSTR ,LPCTSTR 之间关系和区别 CString 是一个动态 TCHAR 数组,BSTR 是一种专有格式的字符串(需要用系统提供的函数来 操纵...

  • Java中常用数据类型转换

    Java中常用数据类型转换_IT/计算机_专业资料。Java中常用数据类型之间的转换Java 中常用数据类型之间转换的方法 Java 中几种常用的数据类型之间转换方法: 1. short...

  • VC常用数据类型转换

    VC 常用数据类型转换 VC 常用数据类型转换 2009-11-27 10:10 91 人阅读 评论(0) 收藏 举报 一、BSTR、LPSTR 和 LPWSTR 在 Visual C++.NET 的所有编程方式...

  • VC常见数据类型转换

    VC 常见数据类型转换一、其它数据类型转换为字符串 短整型(int) itoa(i,temp,10);///将 i 转换为字符串放入 temp 中,最后一个数字表示十进制 itoa(i,temp,...

  • 常用数据类型使用转换详解

    VC常用数据类型使用转换详解VC常用数据类型使用转换详解隐藏>> 我们先定义一些常见类型变量借以说明 int i = 100; long l = 2001; float f=300.2; double d...

  • VC常用数据类型使用转换详解

    VC常用数据类型使用转换详解 刚接触VC编程的朋友往往对许多数据类型的转换感到迷惑不解,本文将介绍一些常用数据类型的使用。 我们先定义一些常见类型变量借以说明 int...

  • 常用数据类型使用转换详解

    常用数据类型使用转换详解 刚接触 VC 编程的朋友往往对许多数据类型的转换感到迷惑不解 ,本文将介绍一 些常用数据类型的使用。 我们先定义一些常见类型变量借以说明...

  • C语言各种数值类型转换

    各种数值类型转换函数 常用到字符串和数字的转换,想找却发现网上的资料太散 所以搜集整理一下 方便以后再用 atof(将字符串转换成浮点型数) atoi(将字符串转换成...

站点地图 | 文档上传 | 侵权投诉 | 手机版
本站所有资源均来自互联网,本站只负责收集和整理,均不承担任何法律责任,如有侵权等其它行为请联系我们.
文档下载 Copyright 2013 doc.guandang.net All Rights Reserved.  -  email