CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 15 of 20

Threaded View

  1. #4
    Join Date
    Jun 2003
    Location
    Gjøvik, Norway
    Posts
    204
    Use std::bitset:
    Code:
    #include <iostream>
    #include <fstream>
    #include <bitset>
    
    int main()
    	{
    	std::ifstream InFile("binary.txt");
    	std::bitset<8> Byte;
        
    	if(!InFile)
    		{
    		std::cerr << "Unable to open the file." << std::endl;
    		return 1;
    		}
    	
    	while(InFile >> Byte)
    		{
    		std::cout << Byte << ": " << static_cast<char>(Byte.to_ulong()) << std::endl;
    		}
    
    	system("pause");
    	return 0;
    	}
    And that's #include <string> NOT #include <string.h>...

    EDIT: Too late..
    Last edited by Assmaster; April 6th, 2004 at 11:46 AM.

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