我几天前发布了我的问题,而我还在处理我的代码。我将重申我的问题,以便每个人都清楚。
目标:使用循环打印所有可用的Unicodes。
问题:为什么我只能将它们作为符号打印出来,如果它们是用字符串硬编码而不是变量。
输出:
U000000
U000001
U000002
...
U000017
U000018
#include <iostream>
#include <cmath>
using namespace std;
const int HexBase=16;
const int HexMax=15;
const int UniCharMaxPrint=1000;
const int ASCCIAlphaCapBase=48;
int main() {
int DecNum = 0;
int sizeHex= 3;
for (int j=0; j < UniCharMaxPrint; j++)//prints 100 unviersal Chars
{
int DecNumCopy = DecNum;
int resultDiv =0;
string HexChar=" ";
string HexNum ="X";
string UniNum ="u";
string BackSlash = "\\";
string full="HI ";
for (int i = sizeHex; i >=0; i--)
{
//Dec calcultion
resultDiv = (DecNumCopy/(int)(pow(HexBase,i)));
DecNumCopy = DecNumCopy - ((int)(pow(HexBase,i)) * resultDiv);
if ((i==0) && (resultDiv>HexMax)){cout <<"Error # is Too large"<<endl;}//Check if the number entered is big or not
//Get the equivalente Hex charcter
if ((resultDiv >= 0)&&(resultDiv <= 9))
{ HexChar = ASCCIAlphaCapBase + resultDiv;}
else if ((resultDiv >= 10)&&(resultDiv <= 15))
{ switch (resultDiv)
{ case 10 : {HexChar='a'; break;};
case 11 : {HexChar='b'; break;};
case 12 : {HexChar='c'; break;};
case 13 : {HexChar='d'; break;};
case 14 : {HexChar='e'; break;};
case 15 : {HexChar='f'; break;};
}
}
else {HexChar='*';};
//if(i==sizeHex){full.append(UniNum);};
//Add to the result string
//HexNum.append(HexChar);
UniNum.append(HexChar);
full = BackSlash+UniNum;
}//endfor
DecNum++;
cout<< full << endl;
}
return 0;
}