Hii Friends,
I do not know how to use FILE for writing data.
I have tried something but i missed something to write and i do not know what to write now to get data inside file.
Help me plz.
Regards,
Shivi
#include <iostream>
#include "circle.h"
using namespace std;
double Circle::getarea() const
{
return 3.14*radius*radius;
}
double Circle::setradius(double r)
{
radius = r;
}
int main()
{
Circle c1;
FILE *fp;
cout<<"Enter the radius: ";
double rad;
cin>>rad;
c1.setradius(rad);
double area = c1.getarea();
cout<<"area of circle: "<<area<<endl;
fp = fopen("area.dat", "w");
printf("%d\n", c1.getarea());
fclose(fp);
return 0;
}
circle.h
#ifndef CIRCLE_H_
#define CIRCLE_H_
#include<iostream>
using namespace std;
class Circle
{
public:
Circle() {};
double getarea() const;
double setradius(double r);
private:
double radius;
double a;
};
#endif