I need to write a C script with which I should be able to count all letters on each line in a text file and print each value. The text file has to be a parameter given when running the C script.
#include <stdio.h>
#include <string.h>
int main(int argc,char * argv[])
{
    char *g, linie[1000];
    int nrChar=0;
    FILE *f=fopen(argv[1],"r");
    g=fgets(linie,1000,f);
    while(g!=NULL)
    {
    nrChar=strlen(linie)-2;
    printf("cuv is %d\n",nrChar);
        g++;
        g=fgets(linie,1000,f);     
    }   
    fclose(f);
    return 0;
}
This is what I tried, but it doesn't work.
I am expecting something like:
2
3
5
4
1
Supposing I have a .txt file which contains:
do
abc
linux
bash
c
 
    