Professional Documents
Culture Documents
/* Implementation of File
Created by: Biplob Banik
*/
#include<iostream>
#include<fstream>
#include<conio.h>
using namespace std;
int main(){
ifstream infile("D:\\New folder\\CPP\\fst");
int m,n;
cout<<"Enter the starting index"<<endl;
cin>>m;
cout<<"Enter the ending index"<<endl;
cin>>n;
int i=0;
char text[100];
while(infile){
i++;
infile.getline(text,100);
if(i>=m && i<=n)
cout<<text<<endl;
}
getch();
return (0);
}
Output:
Discussion:
In this program we at first create a notepad file and something into it.
Then we code a program that will take a starting index and an ending index
from the user and give the contents between the given line numbers .
_________________________________