Chr() or joining two different data types
Actually this is to do with C++. I would post it in the C++ section, but it looks too slow and I need an answer fairly quickly.
Is there a function which is equivelant to VB's Chr() function in C++? I'm new to C++ and I am converting some simple code from VB to C++ but it doesn't seem to be working. I want a function to return a string, but the string's length keeps changing. Here's the code if it helps:
Code:
#include <string>
#include <strstream>
#include <iostream>
using namespace std;
int main()
{
unsigned long lngInput;
unsigned long lngOInput;
string strOutput;
unsigned char intChar;
cout << "Please enter a number to convert to Base 32" << endl;
cin >> lngInput;
lngOInput = lngInput;
while( lngInput != 0 )
{
if( lngInput % 32 < 10 )
{
intChar = ((lngInput % 32) + 48);
strOutput = intChar & strOutput;
}
else
{
intChar = ((lngInput % 32) + 55);
strOutput = intChar & strOutput;
}
lngInput = int(lngInput / 32);
}
cout << lngOInput << " in base 32 is " << strOutput << endl;
return 0;
}
Yes, I know that it is returning an integer, but that's only because it won't work as a string. Once strOutput shows the right thing I will change it. intChar is the character I want to convert (using something like chr()).
Any help would be appreciated, thanks.