User Profile
Collapse
-
Interesting. Thank you for the information, I appreciate it very much.... -
Thank you for your explanation that makes a lot of sense, I tried using the ignore() function but that didn't seem to work. According to your theory it should have though right?
You said:
"then the fin >> integerNumber fetches the 5 and leave you positioned at trhe space right after the 5 and before the C. This is where your fin.getline(nam e, 20) will start. That means your 20 will stop one byte short of the...Leave a comment:
-
if I use "fin" as my file input stream I should be able to gather all of the data from this line using:
for some...Code:fin >> integerNumber; // where this is an integer fin.getline(name, 20); // character array fin >> doubleNumber; // double fin >> integerNumber2; // integer fin >> integerNumber1; // integer fin >> characterF; // character
Leave a comment:
-
Well I figured that part out.
after I input the array of characters i used the "inEmp.clear(); " function like this:
I still don't know why there was anything IN the buffer when I was done, maybe I need to use the cin.get() instead of cin.getline()....Code:inEmp.ignore(); inEmp.getline(empNam,(MAX_CHARS)); emp[empCount].setName(empNam); inEmp.clear();
Leave a comment:
-
if you're writing to a file you could just "fout" that information at the end of the function and loop the whole thing....Leave a comment:
-
my idea is to just change your [i] to a [j]. If that's how you have your array set up.
...Code:for(int i=0;i<5;i++) { cout<<"Give the name of the student "<<i+1<<": "; cin>>names[i]; cout<<"Give the four test score for "<<names[i]; for(int j=0;j<4;j++) { cout<<"Test "<<j+1<<" : ";Leave a comment:
-
int determinePage(i nt virtual_addr){
int page_num;
int page_size = 4096;
page_num = floor(virtual_a ddr/page_size);
return page_num;
}
your page_num = floor(virtual_a ddr/page_size)
is setting page_num = floor(array with 10 values divided by page_size);
you can't use an array like this, you have to pick a value from the array, or make a loop to use every value from the array....Leave a comment:
-
How to input values from file
Input file looks like this:
5 Christine Kim...... 30.00 2 1 F
15 Ray Allrich 10.25 0 0 M
16 Adrian Bailey 12.50 0 0 F
with exactly 20 characters from the start of the name to the null before the double.
using
...Code:int empNum, empDep, empTyp; char empNam[MAX_CHARS]; double empRat; ifstream inEmp; inEmp.open("master7.txt");
No activity results to display
Show More
Leave a comment: