int number is a paramter for the function this code is from.
first_digit
is a string that has been passed the first value from a ifstream file
else if (number != 0)
{
std::string number_string = std::to_string(number);
while (!file.eof() )
{
if (first_digit[0] == number_string)
{
count++;
}
file >> first_digit;
}
What I am trying to do is have count++
iff the first digit from the file matches the char value of parameter int number
. AKA I am trying to count the lines for which the first digit matches number
. number
is passed from a separate function that will send number for(i=1;1<10;i++)
so that I will end with a total sum for the number of times the first digit in the file is 1, 2, 3 etc etc
What I am struggling with is the conditional! How can I relate the first index position of string first_digit to int n on the basis of they hold the same char value? e.g. '1' == '1'
therefore count++