CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Jun 2010
    Location
    Germany
    Posts
    2,675

    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;
    }

  2. #2
    Join Date
    Jun 2010
    Location
    Germany
    Posts
    2,675

    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;
    }

  3. #3
    Join Date
    Jun 2010
    Location
    Germany
    Posts
    2,675

    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
  •  





Click Here to Expand Forum to Full Width

Featured