-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path2.cpp
36 lines (33 loc) · 807 Bytes
/
2.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
/*
2. Write a C/C++ program that reads text from a file, then count and prints the number of line exist in the inputted text file.
*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define fl(i, a, n) for (int i = a; i < n; i++)
#define pb push_back
#define all(p) p.begin(), p.end()
#define rall(v) v.rbegin(), v.rend()
#define vi vector<int>
#define vvi vector<vi>
#define imr_an ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
void solve(){
ifstream inputFile("input.txt");
if(!inputFile){
cout<<"file not found"<<endl;
return;
}
string s;
int line=0;
while(getline(inputFile,s))line++;
cout<<line<<endl;
inputFile.close();
}
int main()
{
imr_an
int t=1;
// cin>>t;
while(t--)solve();
return 0;
}