Expand|Select|Wrap|Line Numbers
- #include <iostream>
- #include <fstream>
- #include <string>
- using namespace std;
- int main()
- {
- string line;
- ifstream file("a7N.txt");
- if (file.is_open())
- {
- while (! file.eof() )
- {
- getline (file,line);
- cout <<line << endl;
- }
- system("PAUSE");
- ifstream file("a7N.txt");
- char ch, fword;
- string line1, num, num2,line4;
- ;
- if(file >>ch>> line1 >> num >> num2 >>line4) {
- cout << "[ "
- << ch << ' '
- << line1 << ' '
- << num << ' '
- << num2 << ' '
- << line4<<" ]"
- << endl;
- ;
- }
- // read a line using getline
- if(getline(file,line)) {
- cout << "[ " << line << " ]" << endl;
- cout<<"Please enter a Capital letter?";
- cin>>fword;
- if (ch == fword)
- cout << "[ "
- << ch << ' '
- << line1 << ' '
- << num << ' '
- << num2 << ' '
- << line4<<" ]"
- <<endl;
- else
- cout<< "No Name starts with that letter!"<<endl;
- system("PAUSE");
- return 0;
- }
- }
- }