Unused Character

Upon compilation I get a warning saying that "variable ā€˜zā€™ set but not used". How do I fix this?

1
2
3
4
5
6
7
8
9
10
11
12
  void num_chars(vector<string> words)
{
    ifstream fin(words[1]);
    char z = fin.get();
    int char_count = 0;
    while (!fin.eof())
    {
        ++char_count;
        z = fin.get();
    }
    cout << words[1] << " contains " << char_count << " characters. \n\n";
}
Why are you initializing z as fin.get() and then assigning it to fin.get() again, inside the while loop?

Also, is there any way we can get the rest of your program? It makes troubleshooting monumentally easier.
Last edited on
Topic archived. No new replies allowed.