Code:
#include <iostream.h>
#include <fstream.h>
#include <stdlib.h>
void read_file ();
int main()
{
char yesno;
cout<<"Display conents of directory [y/n]"<<endl;
yesno = getch();
switch(yesno)
{
case 'n':
cout<<"Ok, Exiting..."<<endl;
return 0;
break;
case 'y':
cout<<"Loading..."<<endl;
system("dir > dir.txt");
read_file();
break;
default:
cout<<"Not an option..."<<endl;
return 0;
break;
}
return 0;
}
void read_file()
{
char content[1000];
ifstream load;
load.open("dir.txt");
load.read(content, 1000);
load.close();
cout<<content<<endl;
cout<<"Closeing..."<<endl;
system("pause");
}
You might have to clean it up before it compiles but that should work...