在C ++中将ASCII值语句转换为其等效字符串
在本教程中,我们将讨论将ASCII值句子转换为其等效字符串的程序。
为此,我们将提供一个包含ASCII码的字符串。我们的任务是将给定的字符串转换为等效的字符并将其打印回来。
示例
#include <bits/stdc++.h>
using namespace std;
//将ASCII序列转换为
//字符串
void convert_ASCII(string str, int len){
int num = 0;
for (int i = 0; i < len; i++) {
//附加当前数字
num = num * 10 + (str[i] - '0');
//检查数字是否在范围内
if (num >= 32 && num <= 122) {
char ch = (char)num;
cout << ch;
num = 0;
}
}
}
int main(){
string str = "104101108108111443211911111410810033";
int len = str.length();
convert_ASCII(str, len);
return 0;
}输出结果
hello, world!
热门推荐
10 对患者生日祝福语简短
11 结婚祝福语简短装备
12 周岁祝福语学生文案简短
13 订婚领证祝福语简短精辟
14 导师获奖祝福语大全简短
15 新婚购房祝福语简短精辟
16 牛年祝福语简短的爱人
17 送芒果的祝福语简短
18 送给学长毕业祝福语简短