Hey,
I am tying to convert an int to a char. Below is an example of the code that I have but I am getting an error('=':left operand must be l-value). I am not seeing a problem with the code.
1 2 3 4 5 6
int num = 5;
char temp[2];
char final[2];
itoa(num, temp, 10);
m_pRes->final = temp;
Any help on this will be greatly appreciated!!
Thanks In Advance
#include <stdio.h>
#include <iostream>
using std::cout;
int main()
{
int a = 339;
char b = a;
char c = (char)a;
int d = (int)b;
int e = a & 0xff;
cout << a << " " << b << " " << c << " " << d << " " << e << std::endl;
}
from the output we can see that the way that casting (char)num works is the same way as logicaly AND the int with only the first 8 bits.
what I dont understand in your code is m_pRes and itoa, what you need em for? just use casting