Aim: To Study Implementation of File Allocation Strategies (Indexed) - Theory
Aim: To Study Implementation of File Allocation Strategies (Indexed) - Theory
Advantages:
This supports direct access to the blocks occupied by the file and therefore provides
fast access to the file blocks.
It overcomes the problem of external fragmentation.
Program:
#include <iostream>
#include <iomanip>
#include <fstream>
#include<string>
using namespace std;
int main() {
int sum = 0;
string x;
ifstream inFile;
inFile.open("test.txt");
if (!inFile) {
cout << "Unable to open file";
exit(1);
}
string s = "failure";
int flag = 0;
string t;
cout<<"Enter index";
cin>>t;
while (inFile >> x) {
if(flag){
cout<<"Word found :"<<x<<" ";
flag = 0;
}
if(x == t){
flag = 1;
}
}
inFile.close();
return 0;
}
Output:
Conclusion:
Sequential file allocation method studied successfully and implemented.