Directory Listing | |
---|---|
array_reference.cpp
|
|
getline.cpp
|
|
isstream.cpp
|
|
namelist.txt
|
|
numbers.txt
|
|
osstream.cpp
|
|
recordgen.c
|
|
result2.txt
|
|
result4.txt
|
|
student_info.cpp
|
|
sum.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
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
using namespace std;
int main() {
string filename;
//Request filename
cout << "Input filename: ";
cin >> filename;
ifstream fp;
fp.open(filename);
//Get the first line of the file
string line;
getline(fp, line);
fp.close();
//Print
cout << line << endl;
}