-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path1.cpp
37 lines (34 loc) · 944 Bytes
/
1.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
37
/*
1. Write a C/C++ program that reads text from a file and prints on the terminal each input line, preceded by the line number. The output will look like -
- 1 This is the first trial line in the file,
- 2 and this is the second line.
*/
#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 lineTrack=1;
while(getline(inputFile,s))cout<<lineTrack++<<" "<<s<<endl;
inputFile.close();
}
int main()
{
imr_an
int t=1;
// cin>>t;
while(t--)solve();
return 0;
}