ذخيره و بازيابي

18
/ ي ب ا ي از ره و ي ي خ ذ

Upload: amy-weeks

Post on 02-Jan-2016

15 views

Category:

Documents


2 download

DESCRIPTION

/. ذخيره و بازيابي. 5 ذخیره بازیابی در C++. ذخیره و بازیابی در C++. # include # include main () } fstream f1 ; f1.open("d:\\aaa.txt",ios::out); f1

TRANSCRIPT

/ ذخيره و بازيابي

5ذخیره بازیابی در

C++

++Cذخیره و بازیابی در #include<iostream.h>

#include<fstream.h>

main()

}

fstream f1;

f1.open("d:\\aaa.txt",ios::out);

f1<<"Ali Reza”;

{

++Cذخیره و بازیابی در #include<iostream.h>

#include<fstream.h>

main()

{

fstream f1;

f1.open("d:\\aaa.txt",ios::app);

f1<<"Ali Reza"<<endl;

}

++Cذخیره و بازیابی در

#include<iostream.h>#include<fstream.h>main(){

fstream f1;f1.open("d:\\aaa.txt",ios::out);f1<<"Ali Reza"<<endl;f1<<"Hamid";

}

++Cذخیره و بازیابی در #include<iostream.h>#include<fstream.h>main(){

fstream f1;char a;f1.open("d:\\aaa.txt",ios::in);f1>>a;cout<<a;

}

++Cذخیره و بازیابی در #include<iostream.h>#include<fstream.h>main(){

fstream f1;char a[5];f1.open("d:\\aaa.txt",ios::in);f1>>a;cout<<a;

}

<C++#include<iostream.hذخیره و بازیابی در #include<fstream.h>main(){

fstream f1;char a;f1.open("d:\\aaa.txt",ios::in);f1>>a;cout<<a;f1>>a;cout<<a;f1>>a;cout<<a;f1>>a;cout<<a;f1>>a;cout<<a;

}

<C++#include<iostream.hذخیره و بازیابی در #include<fstream.h>main(){

fstream f1;char a;f1.open("d:\\aaa.txt",ios::in);f1.unsetf(ios::skipws);f1>>a;cout<<a;f1>>a;cout<<a;f1>>a;cout<<a;f1>>a;cout<<a;f1>>a;cout<<a;

}

<C++#include<iostream.hذخیره و بازیابی در

#include<fstream.h>

main()

{

fstream f1;

char a;

f1.open("d:\\aaa.txt",ios::in);

f1.unsetf(ios::skipws);

for(int c=0;c<=20;c++)

{

f1>>a;

cout<<a;

}

}

<C++#include<iostream.hذخیره و بازیابی در #include<fstream.h>main(){

fstream f1;char a;f1.open("d:\\aaa.txt",ios::in);f1.unsetf(ios::skipws);for(int c=0;c<=20;c++){

f1>>a;cout<<a;cout<<f1.eof();

}}

<C++#include<iostream.hذخیره و بازیابی در

#include<fstream.h>

main()

{

fstream f1;

char a;

f1.open("d:\\aaa.txt",ios::in);

f1.unsetf(ios::skipws);

while(!f1.eof())

{

f1>>a;

cout<<a;

}

}

++Cذخیره و بازیابی در main(){

fstream f1,f2;char a,b;f1.open("d:\\aaa.txt",ios::in);f2.open("d:\\bbb.txt",ios::out);f1.unsetf(ios::skipws);while(!f1.eof()){

f1>>a;if(f1.eof())

b=' ';else

f1>>b;f2<<b<<a;

}f1.close();f2.close();

}

++Cذخیره و بازیابی در #include<iostream.h>

#include<fstream.h>

main()

{

fstream f1;

char a[20];

cin>>a;

f1.open("d:\\aaa.txt",ios::app);

f1<<a<<endl;

}

++Cذخیره و بازیابی در #include<iostream.h>

#include<fstream.h>

main()

{

fstream f1;

char Name[20];

char Fam[30];

char Tell[20];

cout<<"Enter Name = ";cin>>Name;

cout<<"Enter Fam = ";cin>>Fam;

cout<<"Enter Tell = ";cin>>Tell;

f1.open("d:\\aaa.txt",ios::app);

f1<< Name<<" "<<Fam<<" "<<Tell <<endl;

cout<<"Saved"<<endl;

}

++Cذخیره و بازیابی در #include<iostream.h>#include<fstream.h>main(){

fstream f1;int n;char Name[20];char Fam[30];char Tell[20];cout<<" Name "<<'\t'<<" Fam "<<'\t'<<" Tell "<<endl;cout<<"-------"<<'\t'<<"-------"<<'\t'<<"-------"<<endl;f1.open("d:\\aaa.txt",ios::in);while(!f1.eof()){

f1>>Name>>Fam>>Tell;cout<<Name<<'\t'<<Fam<<'\t'<<Tell<<endl;

}}

++Cذخیره و بازیابی در #include<iostream.h>#include<fstream.h>#include<string.h>main(){

fstream f1;char Name[20];char Fam[30];char Tell[20];char SearchFam[30];cout<<"Enter fam for search = "; cin>>SearchFam;cout<<endl;cout<<" Name "<<'\t'<<" Fam "<<'\t'<<" Tell "<<endl;cout<<"-------"<<'\t'<<"-------"<<'\t'<<"-------"<<endl;f1.open("d:\\aaa.txt",ios::in);while(!f1.eof()){

f1>>Name>>Fam>>Tell;if(!strcmp(SearchFam,Fam))

cout<<Name<<'\t'<<Fam<<'\t'<<Tell<<endl;}

}

++Cذخیره و بازیابی در #include<iostream.h>#include<fstream.h>#include<string.h>main(){

fstream f1;int Menu;char Name[20];char Fam[30];char Tell[20];char Search[30];cout <<"Enter Choise:"<<endl;cout <<"1-Name"<<endl;cout <<"2-Fam"<<endl;cout <<"3-Tell"<<endl;cout <<"Select Menu:";cin >> Menu;cout<<"Enter Item for search = "; cin>>Search;f1.open("d:\\aaa.txt",ios::in);cout<<endl;cout<<" Name "<<'\t'<<" Fam "<<'\t'<<" Tell "<<endl;cout<<"-------"<<'\t'<<"-------"<<'\t'<<"-------"<<endl;

while(!f1.eof()){

f1>>Name>>Fam>>Tell;if(Menu==1)

if(!strcmp(Search,Name))cout<<Name<<'\t'<<Fam<<'\t'<<Tell<<endl;

if(Menu==2)if(!strcmp(Search,Fam))

cout<<Name<<'\t'<<Fam<<'\t'<<Tell<<endl;if(Menu==3)

if(!strcmp(Search,Tell))cout<<Name<<'\t'<<Fam<<'\t'<<Tell<<endl;

}}