c++ - 在不获取 Ascii dec 值的情况下将 char 转换为 int
问题描述
我尝试从文本文件中读取数据。istream 的 .get 函数在 txt 文件中读取 5,但返回相应的 ascii dec 值,即 53。我想将该值转换为 5。
文本文件的一行格式如下:
格式:[文本] = [值]
例如:配置值 = 5
.
从文本文件中读取的代码是:
tmpTxt.ignore(100, '='); //skips past the =
tmpTxt.ignore(100, ' '); //skips past the space
ConfigVec.push_back(tmpTxt.get()); //reads value and pushes it back to the vector(I want this value to be 5)
解决方案
推荐阅读
- bigdata - 如何配置纱线集群以并行执行应用程序?
- android - React Native Android 应用程序卡在启动画面
- java - 如何转换集合
使用 Java8 Lambda 表达式到 Long[] 数组 - httpclient - 在 spfx webpart 中使用 SPHttpClient 将文件上传到 SharePoint Online
- ios - 在 phonegap 应用程序中通过 config.xml 编辑 info.plist 文件?
- excel - excel vba代码密码保护不会消失
- ssl - 如何使用 RusTLS 使用已知的公钥和 PKCS1 填充来加密字节片?
- database - 使用 Grails 作为框架时尝试查看 H2 数据库中的表
- android - 从片段中获取输入数据
- batch-file - 通过网络删除文件夹