Help with Mode loop

Trying to find the mode in a file here is my code Mode coming out as 0 instead of a number in the code
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#include <iostream>
#include <fstream>
using namespace std;
int main () {
    const int SIZE=100;
    fstream luffy;
    luffy.open("ages.dat.txt");
    if (!luffy)
        cerr <<"No File" <<endl;
    else
        cout <<"Daddy" <<endl;
    char buff[SIZE];
    while (luffy.getline(buff, SIZE))
        cout <<buff <<endl;
    luffy.close();
    cout <<endl;;
    luffy.open("ages.dat.txt");
    while (luffy.getline(buff, SIZE)){
        int number = buff[0];
        int mode = number;
        int count = 1;
        int countMode = 1;

        for (int i=1; i<SIZE; i++)
        {
            if (buff[i] == number)
      { // count occurrences of the current number
         ++count;
      }
      else
      { // now this is a different number
            if (count > countMode)
            {
                  countMode = count; // mode is the biggest ocurrences
                  mode = number;
            }
           count = 1; // reset count for the new number
           number = buff[i];
  }
}

cout << "mode : " << mode << endl;
    }
}
Your code needs to read from a file to work properly.
Do you think sharing that file with us could be a good idea?
closed account (1vf9z8AR)
i use this to read from file
header file- string.h

inside main- string line;
while(luffy>>line)
cout<<line;
Topic archived. No new replies allowed.