if(input.is_open() && output.is_open())
{
while(!input.eof())
{
char a=NULL;
getline(input,line);
while(!line.empty())
{
int num=0;
string byte=line.substr(0,8);
for(int i=0;i<byte.length();i++)
{
if(byte.at(i)==1)
{
num=num+pow(2,8-i);
}
else
{
num+=0;
}
}
output << num << " ";
line=line.substr(8);
}
}
}
I want to read from file which one line is 32 bit binary number take 8 bits from it and transform decimal. But above code give always 0.