I have to write a function which reads from a file and allocate it . if it is binary file open for binary or if it is text file function must open it in that way
void /*function name*/(char filename){
fstream filereader;
filereader.open(filename);
//rest of the code, u will have to write document.txt (the extension) but thats a secondary thing.
}
Edit:
The following code is a code that opens files and outputs the content:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
#include <iostream>
#include <fstream>
usingnamespace std;
int main () {
char c, str[256];
ifstream is;
cout << "Name of the file: ";
cin.get (str,256);
is.open (str);
while (is.good())
{
c = is.get();
if (is.good())
cout << c;
}
is.close();
}