首页 > 解决方案 > 在不获取 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)

标签: c++vectorcharintegerascii

解决方案


推荐阅读