Clones of simple Unix commands

Tasks

Task Write a simple clone of the following commands:

#include <stdio.h>
#include <stdbool.h>

int main() {
    int i = 1;
    bool startOfLine = true;
    while(true) {
        char c;
        scanf("%c", &c);
        if(feof(stdin))
            break;
        if (startOfLine) {
            printf("%6d  ", i);
            startOfLine = 0;
        }
        if (c == '\n') {
            ++i;
            startOfLine = true;
        }
        printf("%c", c);
    }
    return 0;
}
#include <iostream>
#include <string>

using std::cin;
using std::cout;
using std::string;
using std::getline;

int main() {
    int i = 0;
    string s;
    while(getline(cin, s)) {
        ++i;
        cout << i << ' ' << s << '\n';
    }
    return 0;
}
#include <stdio.h>
#include <stdbool.h>
#include <ctype.h>

int main() {
    int lines = 0;
    int words = 0;
    int chars = 0;
    bool startOfLine = true;
    bool startOfWord = true;
    while(true) {
        char c;
        scanf("%c", &c);
        if(feof(stdin))
            break;
        if (startOfLine) {
            ++lines;
            startOfLine = false;
        }
        if (startOfWord && !isspace(c)) {
            ++words;
            startOfWord = false;
        }
        ++chars;
        if (c == '\n') {
            startOfLine = true;
        }
        if (isspace(c)) {
            startOfWord = true;
        }
    }
    printf("%8d %8d %8d\n", lines, words, chars);
    return 0;
}
int main() {
    return 0;
}