在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 给英雄的祝福语简短