- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
int boolToInt(bool b)
{
bool * boolPtr = &b;
char * boolToCharPtr = reinterpret_cast<char *>(boolPtr);
char * resultCharPtr;
resultCharPtr = (char*) malloc(4);
for (int i = 0; i < sizeof(int); i++)
{
if (i == 0)
{
resultCharPtr[i] = boolToCharPtr[0];
}
if (i == 1)
{
resultCharPtr[i] = 0x00;
}
if (i == 2)
{
resultCharPtr[i] = 0x00;
}
if (i == 3)
{
resultCharPtr[i] = 0x00;
}
}
int * intPtr = reinterpret_cast<int *> (resultCharPtr);
return *intPtr;
}