User Profile

Collapse

Profile Sidebar

Collapse
BenFedorko
BenFedorko
Last Activity: Jun 2 '10, 06:14 PM
Joined: May 14 '10
Location:
  •  
  • Time
  • Show
  • Source
Clear All
new posts

  • BenFedorko
    replied to How to input values from file
    in C
    Interesting. Thank you for the information, I appreciate it very much....
    See more | Go to post

    Leave a comment:


  • BenFedorko
    replied to How to input values from file
    in C
    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...
    See more | Go to post

    Leave a comment:


  • BenFedorko
    replied to How to input values from file
    in C
    if I use "fin" as my file input stream I should be able to gather all of the data from this line using:

    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
    for some...
    See more | Go to post

    Leave a comment:


  • BenFedorko
    replied to How to input values from file
    in C
    Well I figured that part out.

    after I input the array of characters i used the "inEmp.clear(); " function like this:

    Code:
    	inEmp.ignore();
    	inEmp.getline(empNam,(MAX_CHARS));
    	emp[empCount].setName(empNam);
    	inEmp.clear();
    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()....
    See more | Go to post

    Leave a comment:


  • BenFedorko
    replied to how to change the array in for loop
    in C
    if you're writing to a file you could just "fout" that information at the end of the function and loop the whole thing....
    See more | Go to post

    Leave a comment:


  • BenFedorko
    replied to how to change the array in for loop
    in C
    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<<" : ";
    ...
    See more | Go to post

    Leave a comment:


  • BenFedorko
    replied to How to an array to a function
    in C
    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....
    See more | Go to post

    Leave a comment:


  • BenFedorko
    started a topic How to input values from file
    in C

    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");
    ...
    See more | Go to post
No activity results to display
Show More
Working...