Hie, I have a problem separating characters from integers within an input file in C++.An example of the file contents is given below:
D  5  C  7  C  9  H  4  S  8  D  11  H  13
I want to read and store characters in an array and integers their own array as well, I know how to use fstream but I am stuck on separating the items. I will greatly appreciate any help offered, thank you in advance.
I solved a similar problem last week but there were no characters in that assignment, code is given below for that:
#include <iostream>
#include <fstream>
using namespace std;
int frequencyCal(unsigned short int[][5], unsigned short int, ofstream&);
unsigned short int ScoreForRow(unsigned short int[][5], unsigned short int,      ofstream&);
int main() {
unsigned short int iArray[50][5];
unsigned short int rows = 0;
ifstream fin("YahtzeIn.txt");
ofstream fout("YahtzeOut.txt");
for(unsigned short int i = 0; i < 50; i++) {
    rows += 1;
    for(unsigned short int j = 0; j < 5; j++) {
        fin >> iArray[i][j];
        cout << iArray[i][j] << " ";
        fout << iArray[i][j] << " ";
    }
    cout << "   ==>  " << ScoreForRow(iArray,i,fout) << endl;
    fout << "   ==>  " << ScoreForRow(iArray,i,fout) << endl;
    if(fin.eof())
       break;
}
cout << endl;
fout << endl;
frequencyCal(iArray, rows, fout);
return 0;
}
int frequencyCal(unsigned short int in_array[][5], unsigned short int filerows, ofstream& outfile) {
unsigned short int num1 = 0, num2 = 0, num3 = 0, num4 = 0, num5 = 0, num6 = 0;
// Count the numbers in each row;
for(unsigned short int i = 0; i < filerows; i++)
{
    for(unsigned short int j = 0; j < 5; j++ )
    {  
        // Identify the number and add one to a counter variable
        if(in_array[i][j] == 1) {
           num1+=1;
        }
        else if(in_array[i][j] == 2) {
                num2+=1;
             }
        else if(in_array[i][j] == 3) {
                num3+=1;
             }
        else if(in_array[i][j] == 4) {
                num4+=1;
             }
        else if(in_array[i][j] == 5) {
                num5+=1;
             }
        else if(in_array[i][j] == 6) {
                num6+=1;
             }
    }
}
cout << "Dice frequency" << endl;
cout << "==============" << endl;
cout << "1's    2's    3's    4's    5's    6's" << endl;
outfile << "Dice frequency" << endl;
outfile << "==============" << endl;
outfile << "1's    2's    3's    4's    5's    6's" << endl;
// Print and display the values of the variables;
cout << num1 << "     " << num2 << "     " << num3 << "     " << num4 << "     " << num5 << "     " << num6;
outfile << num1 << "     " << num2 << "     " << num3 << "     " << num4 << "     " << num5 << "     " << num6;
return 0;
}
unsigned short int ScoreForRow(unsigned short int in_array[][5], unsigned short int i, ofstream& outfile) {
unsigned short int numb1 = 0, numb2 = 0, numb3 = 0, numb4 = 0, numb5 = 0, numb6 = 0, score = 0;
bool four = false, five = false;
for(unsigned short int j = 0; j < 5; j++ )
    {  
        // Sum up all numbers in a row
        score += in_array[i][j];
        // check if number occurs twice, three times or five times
        if(in_array[i][j] == 1) {
           numb1+=1;
           if(numb1 == 4) {
              four = true;
           }
           else if(numb1 == 5) {
                    four = false;
                    five = true;
           }
        }
        else if(in_array[i][j] == 2) {
                numb2+=1;
                if(numb2 == 4) {
                    four = true;
                }
                else if(numb2 == 5) {
                        four = false;
                        five = true;
                }
            }
        else if(in_array[i][j] == 3) {
                numb3+=1;
                if(numb3 == 4) {
                    four = true;
                }
                else if(numb3 == 5) {
                        four = false;
                        five = true;
                }
            }
        else if(in_array[i][j] == 4) {
                numb4+=1;
                if(numb4 == 4) {
                    four = true;
                }
                else if(numb4 == 5) {
                        four = false;
                        five = true;
                }
            }
        else if(in_array[i][j] == 5) {
                numb5+=1;
                if(numb5 == 4) {
                    four = true;
                }
                else if(numb5 == 5) {
                        four = false;
                        five = true;
                }
            }
        else if(in_array[i][j] == 6) {
                numb6+=1;
                if(numb6 == 4) {
                    four = true;
                }
                else if(numb6 == 5) {
                        four = false;
                        five = true;
                }
            }
   }
// Check if a number appears twice and another occurs 3 times, if so, update score to 25;    
if(((numb1 == 2) || (numb2 == 2) || (numb3 == 2) || (numb4 == 2) || (numb5 == 2) || (numb6 == 2)) 
&& ((numb1 == 3) || (numb2 == 3) || (numb3 == 3) || (numb4 == 3) || (numb5 == 3) || (numb6 == 3))) {
    score = 25;
}
// Check if a number appears four times
else if(four == true) {
    score = 30;
} 
// Check if a number appears five times
else if(five == true) {
    score = 50;
}
// the value returned  is either sum or number generated by the conditions 
return score;
}