为什么显示结果跟小弟我想要的不对啊百思不得其解,请大哥们帮忙~+

为什么显示结果跟我想要的不对啊?百思不得其解,请大哥们帮忙~+~
// 2.cpp : Defines the entry point for the console application.
//我想要显示的结果是:22Hello World! 但是实际显示是16Hello World! 郁闷

#include "stdafx.h"
#include "stdio.h"
void hctoa(unsigned char ch, unsigned char* hex) 

unsigned char i,c; 

for(i=0;i<2;i++) 

if(i==0) c = ch>>4; 
else c = ch; 
c &= 0x0f; 
if( c>=0 && c<=9 ) *(hex+i) = '0' + c; 
else *(hex+i) = 'A' + c - 10; 



int main(int argc, char* argv[])
{
unsigned char crsp[2];
unsigned char str=22;
unsigned char i;

hctoa(str,crsp);

for(i=0;i<2;i++)
{
printf("%c",crsp[i]);
}

printf("Hello World!\n");
return 0;
}



------解决方案--------------------

楼主是要把数转换成可以显示的字符串吧?

可以用这个函数:

C/C++ code
itoa

------解决方案--------------------
把'0 '、'A '里的空格去掉