Friday, July 31, 2009

Sir, I want to know about the projects on file handling of c language.Please send me the best projects of c?

please send me the best projects on file handling of c language

Sir, I want to know about the projects on file handling of c language.Please send me the best projects of c?
main() {


FILE *fp=fopen("test.txt","r");


char c;


While(fscanf(fp,"%c",%26amp;c)!=EOF) {


printf("%c",c);


}


}
Reply:// my first program in C++





#include %26lt;iostream%26gt;


using namespace std;





int main ()


{


cout %26lt;%26lt; "Hello World!";


return 0;


}








// my second program in C++





#include %26lt;iostream%26gt;





using namespace std;





int main ()


{


cout %26lt;%26lt; "Hello World! ";


cout %26lt;%26lt; "I'm a C++ program";


return 0;


}





/* my second program in C++


with more comments */





#include %26lt;iostream%26gt;


using namespace std;





int main ()


{


cout %26lt;%26lt; "Hello World! "; // prints Hello World!


cout %26lt;%26lt; "I'm a C++ program"; // prints I'm a C++ program


return 0;


}





// friend functions


#include %26lt;iostream%26gt;


using namespace std;





class CRectangle {


int width, height;


public:


void set_values (int, int);


int area () {return (width * height);}


friend CRectangle duplicate (CRectangle);


};





void CRectangle::set_values (int a, int b) {


width = a;


height = b;


}





CRectangle duplicate (CRectangle rectparam)


{


CRectangle rectres;


rectres.width = rectparam.width*2;


rectres.height = rectparam.height*2;


return (rectres);


}





int main () {


CRectangle rect, rectb;


rect.set_values (2,3);


rectb = duplicate (rect);


cout %26lt;%26lt; rectb.area();


return 0;


}





// friend class


#include %26lt;iostream%26gt;


using namespace std;





class CSquare;





class CRectangle {


int width, height;


public:


int area ()


{return (width * height);}


void convert (CSquare a);


};





class CSquare {


private:


int side;


public:


void set_side (int a)


{side=a;}


friend class CRectangle;


};





void CRectangle::convert (CSquare a) {


width = a.side;


height = a.side;


}





int main () {


CSquare sqr;


CRectangle rect;


sqr.set_side(4);


rect.convert(sqr);


cout %26lt;%26lt; rect.area();


return 0;


}





// vectors: overloading operators example


#include %26lt;iostream%26gt;


using namespace std;





class CVector {


public:


int x,y;


CVector () {};


CVector (int,int);


CVector operator + (CVector);


};





CVector::CVector (int a, int b) {


x = a;


y = b;


}





CVector CVector::operator+ (CVector param) {


CVector temp;


temp.x = x + param.x;


temp.y = y + param.y;


return (temp);


}





int main () {


CVector a (3,1);


CVector b (1,2);


CVector c;


c = a + b;


cout %26lt;%26lt; c.x %26lt;%26lt; "," %26lt;%26lt; c.y;


return 0;


}








#include %26lt;iostream%26gt;


using namespace std;





class CRectangle {


int x, y;


public:


void set_values (int,int);


int area () {return (x*y);}


};





void CRectangle::set_values (int a, int b) {


x = a;


y = b;


}





int main () {


CRectangle rect;


rect.set_values (3,4);


cout %26lt;%26lt; "area: " %26lt;%26lt; rect.area();


return 0;


}
Reply:www.pscode.com


www.sourcecodesworld.com





visit them u ll get a better idea

hollyhock

No comments:

Post a Comment