I am writing a simple C ++ program as my homework to count the number of numbers in a text file. Below is my code, but unfortunately it counts words and numbers. I have no idea how it should count the number of numbers, where is the error?
My text file:
lorem ipsum 5 87 451 13
My code:
#include <iostream>
#include <cstdio>
#include <fstream>
using namespace std;
int main()
{
    int n=0;
    char plik[100], liczby[100];
    
    string nazwapliku;
    nazwapliku="file.txt";
    
    ifstream we("file.txt");
    
    if (!we)
    {
        cout<<"Can't read file'";
        cin.ignore();
        getchar();
        return 1;
    }
    while (!we.eof())
    {
        we>>liczby;
        if(we)
            n=n+1;
    }
    we.close();
    cout<<"Numbers count in "<<nazwapliku<<" : "<<n;
    getchar();
    return 0;
}
 
    