-
August 11th, 2010, 11:51 AM
#1
Pasting code from VC++ 2010 to the forum
This test belongs to this thread. Those who are interested what it's about may have a look there.
This is using the Advanced Editor
VC++ -> forum
Code:
#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
Code:
#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
Code:
#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;
}
-
August 11th, 2010, 11:58 AM
#2
Re: Pasting code from VC++ 2010 to the forum
Now the same with Quick Reply
VC++ -> forum
Code:
#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
Code:
#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
Code:
#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;
}
-
August 11th, 2010, 07:26 PM
#3
Re: Pasting code from VC++ 2010 to the forum
Yet another one, this time using the Standard Editor
VC++ -> forum
Code:
#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;
}
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|