I need to ask the user to type in the file name, and open that file. Here are my functions, can you tell me what I'm doing wrong?
Code:
long AbsoluteLoader (char *ExecutableFilename)
{
int status = 0;
tfile.open (ExecutableFilename);
if (! tfile) //If File cannot be opened
{
cout << "Unable to open";
status = -1;
return status;
};
while ( ! tfile.eof() ){
tfile>>addr >>content;
//Valid address - load memory
if(addr >= 0 && addr < 10000)
{
hypomem[addr] = content;
}
// End of Program
if (addr == -9999) //If PC contains value -9999, End Program
{
cout << "End of Program" << endl ;
status = 0;
return 0;
}
}
tfile.close();
return status;
}
int main()
{
// Read command (Interrupt to the operating system) from the user
cout << "What is the program to run?";
cout << endl << endl;
cin >> ExecutableFilename;
//Load the program
PC = AbsoluteLoader(ExecutableFilename);
}