#include <iostream>
#include <stdio>
using namespace std;
int main()
{
FILE *fp;
// Открываем файл
fp = fopen("filename.txt", "r");
if(fp == NULL)
{
cout << "Невозможно открыть файл: " << ferror(fp) << "\n";
return 1;
}
const int LENGTH = 10000;
int count = 0;
char str[LENGTH];
// Подсчитываем количество строк в файле
while(!feof(fp))
{
fgets(str, LENGTH, fp);
count++;
}
cout << count << "\n";
// Закрываем файл
fclose(fp);
return 0;
}
|