ASCII値の文をC++で同等の文字列に変換します
このチュートリアルでは、ASCII値の文を同等の文字列に変換するプログラムについて説明します。
このために、ASCIIコードを含む文字列が提供されます。私たちのタスクは、指定された文字列を同等の文字に変換して印刷し直すことです。
例
#include <bits/stdc++.h>
using namespace std;
//converting the ASCII sequence into
//character string
void convert_ASCII(string str, int len){
int num = 0;
for (int i = 0; i < len; i++) {
//appending the current digit
num = num * 10 + (str[i] - '0');
//checking if number is within range
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!
-
指定された文字列の値をC#の同等のUnicode文字に変換します
指定された文字列の値を同等のUnicode文字に変換するには、コードは次のとおりです- 例 using System; public class Demo { public static void Main(){ bool res; Char ch; res = Char.TryParse("10", out ch); Console.WriteLine(res); &
-
論理値の指定された文字列表現をC#の同等のブール値に変換します
指定された論理値の文字列表現を同等のブール値に変換するためのコードは、次のとおりです- 例 using System; public class Demo { public static void Main(){ bool val; bool flag; val = Boolean.TryParse("true", out flag); Console.WriteLine("