Counting the number of lines in a file I'm easing back into C after several months of using Python and Matlab. Can anyone give me some pointers on how to improve my code's efficiency and readability?

#include &lt;stdio.h&gt;

#define MAX_ARG 2

int count( char FNAME[] );

int main( int argc, char *argv[]) {
    if( argc &gt; MAX_ARG ) {
        printf("Too many arguments ( %d ) supplied.\n", argc);
        return 0;
    }
    int FILE_LENGTH = 0;
    FILE_LENGTH = count( argv[1] );
    printf("The length of %s is: %d lines.\n", argv[1], FILE_LENGTH);
    return 0;
}

int count( char FNAME[] ) {
    FILE *fp;
    int CHR;
    int LINE_COUNT = 0;
    fp = fopen( FNAME,"r" );
    while( ( CHR = fgetc( fp ) ) != EOF ) {
        if( CHR == '\n' ) {
             LINE_COUNT++;
        }
    }
    fclose( fp );
    return LINE_COUNT;
}
The code starts off very well, with a check to make sure there are not too many arguments, but it doesn't do enough error checking. There could be too few arguments as well (no file name on the command line). Errors in the execution of the file should return a non-zero number and zero for success. Try using the constants EXIT_SUCCESS and EXIT_FAILURE that are defined in stdlib.h. There probably should be an error check to see if fopen() returns a valid file pointer or not.

Generally in C variables are named in lower case, constants and macros are named in all upper case. The constant MAX_ARG follows this standard, but the variables LINE_COUNT, FNAME, FILE_LENGTH and CHR are all opposite to the standard.

The function fgets() would be very useful to the program, and possibly enhance performance. fgets() retrieves a line of text from a file if the buffer supplied is big enough.

You could also input a sector at a time as @Maybe_Factor suggests, although it would probably be better to start testing with 4K, then 8K and up to 64K based on the operating systems blocking factor.