#include <iostream>
#include <fstream>
using namespace std;
void PrintError(fstream&, char, bool&);
int Conversion(fstream&, char&, bool&);
int main()
{
fstream InFile;
char Bit;
int Decimal;
bool BadBit = false;
//Open file to read
InFile.open("f:\\Binary.txt",ios::in);
//Read the first bit of the number
InFile.get(Bit);
//continue reading all numbers till the end of file
while (!InFile.eof())
{
//call Conversion to convert binary to decimal
Decimal = Conversion(InFile, Bit, BadBit);
//check if there is error
if (BadBit)
{
//Print out error message
PrintError(InFile, Bit, BadBit);
}
else
//output the equivalent value of decimal
cout<<" = " <<Decimal<<endl;
//read the next number
InFile.get(Bit);
}
InFile.close();
return 0;
}
int Conversion(fstream& In, char& InBit, bool& Error)
/* Pre: The stream is open for input.
InBit is 1 or 0.
Error indicates the InBit is not One or Zero.
Post: return the conversion of binary to decimal.
Resets Error to true when encounter error.
*/
{
}
void PrintError(fstream& In, char BadOne, bool& Error)
/* Pre: The stream is open for input.
BadOne is bad digit.
Error indicates the BadOne is bad digit.
Post: Prints error message.
Resets Error to false means there is no error.
*/
{
}
hey guys can sum1 plsss do dis program for me.....trust me guys i have been doin it from 3 days but m not able to do it.......pls guys i have a submission tmr....thanks a lot