G
Grant Austin
Hi all,
This is my first time posting so please bear with me.
I would like some criticism of some elementary C++ work I'm doing because
it's been a long long long time and I'm not sure if I'm doing things
correctly/safely.
Particularly I'm having trouble remembering proper use of input streams.
The code I came up with follows at the bottom of the post.
Simply what I need to do is read a file from beginning to end, in hex.
Here is a sample of input:
0 1000
0 2000
0 3000
1 2000
0 4000
2 5000
2 1000
Kind of irrelevent but possibly of interest. The first column of numbers is an action; read,
write, instruction fetch. The second column of numbers is a virtual
address.
The final goal of this program (by Tuesday) is to simulate a handful of
page replacement algorithms.
Regards,
Grant
#include <iomanip.h>
#include <iostream.h>
int main(int argc, char * argv[]) //will be used for cmdline switches
// all input files will come from std input eg. a.out < belady.din
long int a,b;
while(!cin.eof()){
if(!cin.eof())
cin >> hex >> a >> hex >> b;
/* do everything important */
if(!cin.eof())
cout << a << b << endl;
}
}
This is my first time posting so please bear with me.
I would like some criticism of some elementary C++ work I'm doing because
it's been a long long long time and I'm not sure if I'm doing things
correctly/safely.
Particularly I'm having trouble remembering proper use of input streams.
The code I came up with follows at the bottom of the post.
Simply what I need to do is read a file from beginning to end, in hex.
Here is a sample of input:
0 1000
0 2000
0 3000
1 2000
0 4000
2 5000
2 1000
Kind of irrelevent but possibly of interest. The first column of numbers is an action; read,
write, instruction fetch. The second column of numbers is a virtual
address.
The final goal of this program (by Tuesday) is to simulate a handful of
page replacement algorithms.
Regards,
Grant
#include <iomanip.h>
#include <iostream.h>
int main(int argc, char * argv[]) //will be used for cmdline switches
// all input files will come from std input eg. a.out < belady.din
long int a,b;
while(!cin.eof()){
if(!cin.eof())
cin >> hex >> a >> hex >> b;
/* do everything important */
if(!cin.eof())
cout << a << b << endl;
}
}