Click to See Complete Forum and Search --> : Pasting code from VC++ 2010 to the forum


Eri523
August 11th, 2010, 11:51 AM
This test belongs to this thread (http://www.codeguru.com/forum/showthread.php?t=501226). Those who are interested what it's about may have a look there.

This is using the Advanced Editor

VC++ -> forum


#include "stdafx.h"
#include <iostream>
using namespace std;
int setIndexFromBitValue(int allBits, int bitMask)
{
if (allBits & bitMask) return 2; // Bit is set: index is 2
else return 1; // Bit is not set: index is 1
}
int _tmain(int argc, _TCHAR* argv[])
{
int i; // our counter
for (i=0 /* binary 000 */; i<=7 /* binary 111 */; ++i) // enumerate all possible bit combinations
cout << "A" << setIndexFromBitValue(i, 4) // A is bit 2, binary mask is 100
<< ", B" << setIndexFromBitValue(i, 2) // B is bit 1, binary mask 010
<< ", C" << setIndexFromBitValue(i, 1) // C is bit 0, binary mask 001
<< endl;
return 0;
}


File -> Notepad++ -> forum


#include "stdafx.h"
#include <iostream>
using namespace std;
int setIndexFromBitValue(int allBits, int bitMask)
{
if (allBits & bitMask) return 2; // Bit is set: index is 2
else return 1; // Bit is not set: index is 1
}
int _tmain(int argc, _TCHAR* argv[])
{
int i; // our counter
for (i=0 /* binary 000 */; i<=7 /* binary 111 */; ++i) // enumerate all possible bit combinations
cout << "A" << setIndexFromBitValue(i, 4) // A is bit 2, binary mask is 100
<< ", B" << setIndexFromBitValue(i, 2) // B is bit 1, binary mask 010
<< ", C" << setIndexFromBitValue(i, 1) // C is bit 0, binary mask 001
<< endl;
return 0;
}



VC++ -> Notepad++ -> forum


#include "stdafx.h"
#include <iostream>
using namespace std;
int setIndexFromBitValue(int allBits, int bitMask)
{
if (allBits & bitMask) return 2; // Bit is set: index is 2
else return 1; // Bit is not set: index is 1
}
int _tmain(int argc, _TCHAR* argv[])
{
int i; // our counter
for (i=0 /* binary 000 */; i<=7 /* binary 111 */; ++i) // enumerate all possible bit combinations
cout << "A" << setIndexFromBitValue(i, 4) // A is bit 2, binary mask is 100
<< ", B" << setIndexFromBitValue(i, 2) // B is bit 1, binary mask 010
<< ", C" << setIndexFromBitValue(i, 1) // C is bit 0, binary mask 001
<< endl;
return 0;
}

Eri523
August 11th, 2010, 11:58 AM
Now the same with Quick Reply

VC++ -> forum


#include "stdafx.h"

#include <iostream>

using namespace std;

int setIndexFromBitValue(int allBits, int bitMask)
{
if (allBits & bitMask) return 2; // Bit is set: index is 2
else return 1; // Bit is not set: index is 1
}

int _tmain(int argc, _TCHAR* argv[])
{
int i; // our counter

for (i=0 /* binary 000 */; i<=7 /* binary 111 */; ++i) // enumerate all possible bit combinations
cout << "A" << setIndexFromBitValue(i, 4) // A is bit 2, binary mask is 100
<< ", B" << setIndexFromBitValue(i, 2) // B is bit 1, binary mask 010
<< ", C" << setIndexFromBitValue(i, 1) // C is bit 0, binary mask 001
<< endl;
return 0;
}


File -> Notepad++ -> forum


#include "stdafx.h"

#include <iostream>

using namespace std;

int setIndexFromBitValue(int allBits, int bitMask)
{
if (allBits & bitMask) return 2; // Bit is set: index is 2
else return 1; // Bit is not set: index is 1
}

int _tmain(int argc, _TCHAR* argv[])
{
int i; // our counter

for (i=0 /* binary 000 */; i<=7 /* binary 111 */; ++i) // enumerate all possible bit combinations
cout << "A" << setIndexFromBitValue(i, 4) // A is bit 2, binary mask is 100
<< ", B" << setIndexFromBitValue(i, 2) // B is bit 1, binary mask 010
<< ", C" << setIndexFromBitValue(i, 1) // C is bit 0, binary mask 001
<< endl;
return 0;
}


VC++ -> Notepad++ -> forum


#include "stdafx.h"

#include <iostream>

using namespace std;

int setIndexFromBitValue(int allBits, int bitMask)
{
if (allBits & bitMask) return 2; // Bit is set: index is 2
else return 1; // Bit is not set: index is 1
}

int _tmain(int argc, _TCHAR* argv[])
{
int i; // our counter

for (i=0 /* binary 000 */; i<=7 /* binary 111 */; ++i) // enumerate all possible bit combinations
cout << "A" << setIndexFromBitValue(i, 4) // A is bit 2, binary mask is 100
<< ", B" << setIndexFromBitValue(i, 2) // B is bit 1, binary mask 010
<< ", C" << setIndexFromBitValue(i, 1) // C is bit 0, binary mask 001
<< endl;
return 0;
}

Eri523
August 11th, 2010, 07:26 PM
Yet another one, this time using the Standard Editor

VC++ -> forum


#include "stdafx.h"

#include <iostream>

using namespace std;

int setIndexFromBitValue(int allBits, int bitMask)
{
if (allBits & bitMask) return 2; // Bit is set: index is 2
else return 1; // Bit is not set: index is 1
}

int _tmain(int argc, _TCHAR* argv[])
{
int i; // our counter

for (i=0 /* binary 000 */; i<=7 /* binary 111 */; ++i) // enumerate all possible bit combinations
cout << "A" << setIndexFromBitValue(i, 4) // A is bit 2, binary mask is 100
<< ", B" << setIndexFromBitValue(i, 2) // B is bit 1, binary mask 010
<< ", C" << setIndexFromBitValue(i, 1) // C is bit 0, binary mask 001
<< endl;
return 0;
}