Tuesday, July 14, 2009

C++ programming - how to handle int type to char type?

c++ programming:


assume tempNumber are all int type.


for some case, i want to assign certain single alphbet to numberName if tempNumber is certain number; for some other case, i want to assign certain 1-or-2-digit number to numberName. Note: numberName is char type and it will be further handled in char type.





char numberName;


for(int j=0; j%26lt;3; j++)


{


if(tempNumber==1)


{


numberName='a';


}


if(tempNumber==2)


{


numberName='2'; // this line should not correct !


}

C++ programming - how to handle int type to char type?
the problem you're having isn't in this code, it's probably wherever you have the "2-digit" number.





What is the exact error presented by the compiler?


No comments:

Post a Comment