Ive beenn attempting to make a program that reads from a file, and if it reads a B it means the next line is binary and it will translate that next line from binary, into hex and dec and print out binary, then move on to the next line. I am having trouble with #1, going to the next line and #2 having my functions translate.
#include <iostream>
#include <sstream>
#include <fstream>
#include <bitset>
#include <cmath>
#include <string.h>
#include <cstring>
#include <string>
using namespace std;
//creating function to tranlsate hex into decimal
int hexi(char num[]) {
    int len = strlen(num);
    int base = 1;
    int temp = 0;
    for (int i = len - 1; i >= 0; i--) {
        if (num[i] >= '0' && num[i] <= '9') {
            temp += (num[i] - 48) * base;
            base = base * 16;
        }
        else if (num[i] >= 'A' && num[i] <= 'F') {
            temp += (num[i] - 55) * base;
            base = base * 16;
        }
    }
    return temp;
}
int main()
{
    
    {
    string line;
    signed char Binary[6] = { }; //array for binary string
    char Hex[16] = {}; //array for hex string
    double decimal{}; // initilizing decimal value
    char letter; //letter entered
    int rem; //remainder
    unsigned int i = 0; //for binary
    long long n; //for string of 010
    ifstream file;
    file.open("C:\\Users\\18059\\source\\repos\\translation\\input.txt");
    while (true)
    {
        getline(file, line);
        if (file.eof()) break;
        cout << line << " Binary: " << Binary << bitset<6>{i} << " Hexidecimal: " <<  hexi(Hex) << line << " Decimal: " << decimal << endl;
        //getline(file, line);
        
        {
            //read the letter
            cin >> letter;
            //reading if B for binary
            if (letter == 'B')
            {
                cout << endl;
                file >> n;
                while (n != 0) {
                    rem = n % 10;
                    n /= 10;
                    decimal += rem * pow(2, i);
                    ++i;
                }
                cout << "Decimal: " << decimal << endl;
            }
            else if (letter == 'H')
            {
                file >> Hex;
                cout << Hex << "Hexidecimal: " << hexi(Hex) << endl;
                return 0;
            }
        }
        {
            if (letter == 'D')
            {
                file >> decimal;
                cout << "Decimal: " << dec << endl;
            }
        }
    }
    file.close();
    }
}
right now it prints this what it prints
and then my text file looks like this
 
    