C++ Program to Append the Information to a File






 

#include<fstream.h>
#include<stdio.h>
#include<string.h>

struct student
{
int roll;
char name[30];
float marks;
};
student s;
void append()
{
ofstream f1(“File.txt”);
cout<<“Enter the details :”;
cout<<endl;

for(int i=1;i<2;i++)
{
cout<<“Enter the Roll no. : “;
cin>>s.roll;
cout<<endl;
cout<<“Enter the Name :”;
gets(s.name);
cout<<endl;
cout<<“Enter the Marks :”;
cin>>s.marks;

f1.write((char*)&s,sizeof(s));
}
f1.close();
}

void main()
{
append();
cout<<“The new details are :”;
cout<<endl;
ifstream f2(“File.txt”,ios::in);
char ch;
while(f2)
{
f2.get(ch);
cout<<ch;
}
f2.close();
}

Click here for more C++ Programs

info@C++

C++ (pronounced “cee plus plus”).C++ is a general-purpose,powerful programming language.C++ is regarded as an intermediate-level language, as it comprises a combination of both high-level and low-level language features. C++ was Developed by Bjarne Stroustrup starting in 1979.C++ adds OOPS-object oriented features such as classes, and other enhancements to the C programming language.


C++ Program to Append the Information to a File
Rate this post




Further Reading:
http://en.wikipedia.org/wiki/Program
http://en.wikipedia.org/wiki/Append
http://en.wikipedia.org/wiki/Information

You read About: C++ Program to Append the Information to a File

Posted by: Prateek on October 6, 2011


Previous Post: « Next Post: »

© 2017 Trendfy. All rights reserved
Blog Managed by Prateek Jaiswal