#define LONLAT? ? ? ? ? ? ? ? ? ? ? ? ? ? ?"./LonLat_20190128.txt"
int GetTxtLine(const char *filename)
{
? ? FILE *fd;
? ? int count = 0;
? ? if (fd = fopen(filename,"r"))
? ? {
????????while (!feof(fd))
????????{
? ? ????????if ('\n' == fgetc(fd))
? ? ????????{
????????????????count ++;
? ? ? ? ? ? }
????????}
? ? }
? ? printf("count: %d\n", count);
? ? if (fd)
? ? {
????????fclose(fd);
? ? }
? ? return count;
}
使用舉例:
int linecount = 0;
linecount = GetTxtLine(LONLAT?);
linecount的值就是LONLAT 文本里的內(nèi)容總的行數(shù)蓉坎。