| iMatix home page | << | < | > | >> |
SFL Version 2.11 |
#include "sflfile.h" long get_file_lines ( const char *filename)
Reads an entire file, and returns the number of lines in the file. The file should be normal text. Returns 0 if the file cannot be opened for reading. May be a bit slow on large files.
{ long file_size; FILE *file_stream; int ch; ASSERT (filename); file_stream = file open (filename, 'r'); if (file_stream == NULL) return (0); file_size = 0; while ((ch = fgetc (file_stream)) != EOF) if (ch == '\n') file_size++; fclose (file_stream); return (file_size); }
| << | < | > | >> | Copyright © 1996-2000 iMatix Corporation |