出自http://blog.csdn.net/zzyoucan/article/details/10260093

atoi---ASCII to integer,将字符串转换成整形,从数字或正负号开始转换,一直到非数字为止

  1. #include <stdlib.h>
  2. #include <stdio.h>
  3. int main(void)
  4. {
  5. float n;
  6. char *str = "12345.67";
  7. n = atoi(str);
  8. printf("string = %s integer = %d\n", str, n);
  9. return 0;
  10. }

其他的几个类似
itoa---integer to ASCII--将整形转换成字符串

atof---ascii to float--字符串转换成浮点型

atol---ascii to long---字符串转换成长整形

gcvt---浮点型转换成字符串(四舍五入)

strtod---字符串转换成浮点型

strtol---字符串转换成长整形

strtoul--字符串转换成无符号长整形

toascii---将整形转换成合法的ASCII码字符

_ttoi---可以将CString转换成整形

_itot_s---将int转换成char*

    1. CWnd * pWnd = (CWnd*)GetDlgItem(IDC_EDIT4) ;
    2. CString strValue ;
    3. pWnd->GetWindowText(strValue) ;
    4. strValue.Replace(_T("sec"), _T("")) ;
    5. int iValue = _ttoi(strValue) ;//将Cstring转换成int
    6. TCHAR buffer[7] ;
    7. _itot_s(iValue, buffer, 3, 10) ;//将int转换成char*
    8. strValue.Format(_T("%s")) ;//将char*转换成CString
    9. strValue = strValue + _T("sec") ;//CString实现字符串相加

常用的函数:atoi,itoa,atof,_ttoi等的更多相关文章

  1. 模拟实现C库的atoi、atof和itoa

    1.C函数atoi atoi (表示 alphanumeric to integer)是把字符串转换成整型数的一个函数.广泛的应用在计算机程序和办公软件中.atoi( ) 函数会扫描参数 nptr字符 ...

  2. 模拟实现库函数的atoi、atof和itoa

    1.函数atoi atoi (表示 alphanumeric to integer)是把字符串转换成整型数的一个函数.广泛的应用在计算机程序和办公软件中.atoi( ) 函数会扫描参数 nptr字符串 ...

  3. 转载 C++常用库函数atoi,itoa,strcpy,strcmp的实现

    C++常用库函数atoi,itoa,strcpy,strcmp的实现 C语言字符串操作函数 1. 字符串反转 - strRev2. 字符串复制 - strcpy3. 字符串转化为整数 - atoi4. ...

  4. _itoa atoi、atof、itoa、itow _itoa_s 类型转换使用说明

    原文:http://www.cnblogs.com/lidabo/archive/2012/07/10/2584706.html _itoa 功能:把一整数转换为字符串 用法:char * _itoa ...

  5. MFC数据类型转换 _itoa atoi、atof、itoa、itow _itoa_s

    _itoa 功能:把一整数转换为字符串 用法:char * _itoa(int value, char *string, int radix); 详细解释: _itoa是英文integer to ar ...

  6. [c/c++] programming之路(23)、字符串(四)——strncat,atoi,strcmp,strlen等,以及常用内存函数

    一.strncat及自行封装实现 #define _CRT_SECURE_NO_WARNINGS #include<stdio.h> #include<stdlib.h> #i ...

  7. linux常用C函数目录

    字符测试篇 isalnum isalpha isascii iscntrl isdigit isgraphis islower isprint isspace ispunct isupper isxd ...

  8. C语言入门(6)——C语言常用数学函数

    在编码过程中会经遇到数学运算,幸运的是C语言提供了非常丰富的数学函数库. 在数学中使用函数有时候书写可以省略括号,而C语言要求一定要加上括号,例如sin(pi/2)这种形式.在C语言的术语中,pi/2 ...

  9. oracle(sql)基础篇系列(一)——基础select语句、常用sql函数、组函数、分组函数

        花点时间整理下sql基础,温故而知新.文章的demo来自oracle自带的dept,emp,salgrade三张表.解锁scott用户,使用scott用户登录就可以看到自带的表. #使用ora ...

  10. php常用字符串函数小结

    php内置了98个字符串函数(除了基于正则表达式的函数,正则表达式在此不在讨论范围),能够处理字符串中能遇到的每一个方面内容,本文对常用字符串函数进行简单的小结,主要包含以下8部分:1.确定字符串长度 ...

随机推荐

  1. Android Button.getWidth()为0的问题

    View在onCreate的时候,没有渲染组件,所以获取到的宽度和高度为0, 需要添加一个观察者,在layout渲染后再去取宽高.代码如下: private Button btn_icon; @Ove ...

  2. Android开发 string.xml资源添加参数

    挖坑:参考:https://www.cnblogs.com/leelugen/p/6685905.html

  3. eclipse总结source folder和Deployment Assembly部署

    在src下创建多级目录 然后右键build path-->use as source folder 就可以直接将多级普通文件夹转换成source folder build path下也可以直接n ...

  4. 阿里云 Aliplayer高级功能介绍(三):多字幕

    基本介绍 国际化场景下面,播放器支持多字幕,可以有效解决视频的传播障碍难题,该功能适用于视频内容在全球范围内推广,阿里云的媒体处理服务提供接口可以生成多字幕,现在先看一下具体的效果: WebVTT格式 ...

  5. delphi判断MDI窗体的子窗体是否存在

    转]delphi判断MDI窗体的子窗体是否存在//*************************************************************************** ...

  6. go操作空指针导致supervisor进程服务挂机的坑

    一.起因 在数据库中直接手动插入了某条记录,但由于该记录的某个字段的空值,与另一个字段的状态码不符合,在go程序中,突然操作了该空字段的指针,导致程序panic挂机. panic: runtime e ...

  7. 图片压缩(js压缩,底部有vue压缩图片依赖使用的教程链接)

    directTurnIntoBase64(fileObj, callback) { var r = new FileReader(); // 转成base64 r.onload = function( ...

  8. gradle 排除冲突依赖包

    1 , 如何查看jar包依赖源 2 结果显示: 3 排除

  9. MyBatis - Generator(MBG)

    前言 MyBatis Generator简称MBG,是一个专门为MyBatis框架使用者定制的代码生成器, 可以快速的根据数据表自动生成Bean对象.Java接口及SqlMapper.xml配置文件. ...

  10. Neo4j-APOC使用总结(一)

    一.安装APOC 1.下载jar包:https://github.com/neo4j-contrib/neo4j-apoc-procedures/releases 2.把jar包放在安装目录的plug ...