0

Hi! Is it possible to read from specific row on a notepad?
For Example:

Jay
Mark
Christian

I only want to display the word Christian which is on the third row, what will I do? can you please show me? Thanks! Here's my code:

#include <iostream.h>
#include <iomanip.h>
#include <fstream.h>
#include <cstring.h>
#include <string.h>
#include <conio.h>

//using namespace std;

int main()
	{

      char account[80];

	   char string1[] = ".txt";

     	char string2[17];

      cout<<endl;
      cout<<"Enter Account Number: ";
      cin>>account;

      strcpy(string2, account);

     	strcat(string2, string1);


    			int bal = 0;
    			int x;
    			ifstream inFile;

    			inFile.open(string2);
    			if (!inFile) {
        		cout << "Invalid Account";
        		exit(1); // terminate with error

       }
    			while (inFile >> x)
            {
        			bal = bal + x;
            }

    			inFile.close();
    			clrscr();
            cout<<endl;
    			cout<< bal << endl;
    			getch ();
    			return 0;
}
3
Contributors
2
Replies
3
Views
6 Years
Discussion Span
Last Post by WaltP
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.