Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- #include <stdio.h>
- #include <cstdlib>
- using namespace std;
- // varibles for our libary
- int main()
- {
- //varibles for code
- ifstream inputFile;
- string filename, name;
- int count=0;
- // getting our the fille name.
- cout << "Enter the file name (name.txt)" << endl;
- cin >> filename; // putting the stars when each part starts
- cout << "**********" << endl;
- inputFile.open(filename);
- // if statement if the file is open
- if (inputFile){
- while (inputFile >> name){
- count=count + 1;
- // couting the Name,Class,and GPA
- if (name=="Name:"){
- cout << name ;
- }else{
- if (name=="Class:"){
- cout << name ;
- }else{
- if (name=="GPA:"){
- cout << name ;
- }else{
- cout << name << endl;
- }
- }
- }
- //putting the stars after the 3 part is finsihed
- if (count>5){
- count=0;
- cout << "**********" << endl;
- }
- }
- // if file is not open
- }
- else
- {
- cout << "ERROR." << endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement