Sie sind auf Seite 1von 2

#include<iostream.h> #include<ifstream.h> #include<iomanip.h> #include<ofstream.

h> struct tele { char name[20]; int num; }; int main() { struct tele s[10]; int n; cout<<" details of how many people ? :"; cin>>n; for(int i=0;i<=n;i++) { cout<<" enter the name "; cin>>s[i].name; cout<<endl; cout<<"enter the telefone number"; cin>> s[i].num; cout<<endl; } cout<<endl; ofstream outf; outf.open("phonelist.txt"); for(int i=0;i<=n;i++) { cout<<" enter the name "; cin>>s[i].name; cout<<endl; cout<<"enter the telefone number"; cin>> s[i].num; cout<<endl; } cout<<endl; cout.width(20); cout.setf(ios::left,ios::adjustfield); cout.fill(" "); cout<<"NAME"; cout.width(20); cout.setf(ios::right,ios::adjustfield); cout.fill(" "); cout<<"telephone number"; for(i=0;i<=n;i++) { cout.width(20); cout.setf(ios::left,ios::adjustfield); cout.fill(" "); cout<<s[i].name;

cout.width(20); cout.setf(ios::right,ios::adjustfield); cout.fill(" "); cout<<s[i].num; } outf.close() }

Das könnte Ihnen auch gefallen