Sponsored Content
Full Discussion: Feof
Top Forums Programming Feof Post 11405 by primal on Tuesday 4th of December 2001 07:27:38 PM
Old 12-04-2001
Question Feof

Hi Everyone,
I'm having problems with feof
I've storing my variables inside a file, and then in another program, opening that file and recalling the information.
The problem im having is that it's repeating the last set of entries in my while loop.
(if i have one set of product no., quantity, and price in my file, it repeats it twice. if i have two sets or more in my file, it repeats the last set twice)
I think it has something to do with how i have my while(!feof(file)) set up.
Does anyone know what's going on?
Code:
#include[stdio.h]
FILE *invfile;
int prod, qty;
float price;

void main()
    {
     invfile = fopen("file.dat","r");
     while(!feof(invfile))
       {
       fscanf(invfile,"%d %d %f", &prod, &qty, &price);
       printf("Product No.     = %d\n",prod);
       printf("Quantity        = %d\n",qty); 
       printf("Price           = %.2f\n\n",price);
       }
     fclose(invfile);
    }

Thanks!
primal
 
Bonds(1)						      General Commands Manual							  Bonds(1)

NAME
Bonds - Example of bond pricing SYNOPSIS
Bonds DESCRIPTION
Bonds is an example of using QuantLib. It shows how to set up a term structure and then price some simple bonds. The last part is dedicated to peripherical computations such as yield-to-price or price-to-yield. SEE ALSO
The source code Bonds.cpp, BermudanSwaption(1), CallableBonds(1), CDS(1), ConvertibleBonds(1), DiscreteHedging(1), EquityOption(1), Fitted- BondCurve(1), FRA(1), MarketModels(1), Replication(1), Repo(1), SwapValuation(1), the QuantLib documentation and website at http://quantlib.org. AUTHORS
The QuantLib Group (see Authors.txt). This manual page was added by Luigi Ballabio . QuantLib 22 October 2008 Bonds(1)
All times are GMT -4. The time now is 03:46 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy