Siemka mam tutaj program, który liczy liczbę słów w pliku tekstowym jednak nie działa poprawnie i nie wiem gdzie leży błąd.
#include <iostream>
#include <fstream>
#include <string>
int main(){
std::string filename;
std::string line;
std::cout << "Wprowadz nazwe pliku" << std::endl;
std::cin >> filename;
std::ifstream file(filename.c_str());
unsigned int count;
while(std::getline(file,line)){
for(int i = 0;line[i] != '\0';i++){
if(line[i]== ' ') count++;
}
count++;
}
std::cout << "Liczba slow wynosi:" << count << std::endl;
}