I need just to count the number of chars in my 'f' file. When I count a number of chars in one string, I get the real number of it, but when I press 'enter' in my .txt and creating a new line I lose 2 chars. So, having 4 strings with 15 chars at all,my program telling me that there are only 9 chars in the file. Help me please to, just, count this unfortunate chars...
Here is a code in C:
while (!feof(f)) {
bool space = 1; //remembering last char (was it space or not)
for (int i = 0; i < len; ++i) { //running till the end of string
if (a[i] == ' ') {space = 1;}
else if (a[i] != '\0' && a[i] != '\n') {
chars++;
if (space == 1) {
words++; //and counting the words
space = 0;
}
}
}
}