jueves, 16 de mayo de 2013

EJERCICIO EN CLASE 16 MAYO 2013


//ejercicio en clase 16 de mayo del 2013
//villatoro hernandez omar 12211273
//barragan hernandez antonio 12211230
//terrazas flores omar antonio 12211831
#include <iostream.h>
#include <conio.h>
#include <fstream.h>
#include <stdio.h>
void salida_datos_file()
{
ofstream salida;
salida.open("C://Datos//nombres.txt",ios::app);
int i,n;
char name[30];
cout<<" Cuantos nombres desea almacenar: ";
cin>>n;
for(i=1;i<=n;i++)
{
   cout<<" Nombre = ";
 gets(name);
 salida<<name<<endl;
 }
 salida.close();
 }

void entrada_datos_file()
{
ifstream entrada;
entrada.open("C://Datos//nombres.txt");
 char name[30];
 cout<<"\nListado de nombre\n";
 entrada.getline(name,30);
 cout<<name<<endl;
 while(!entrada.eof())
 {
 entrada.getline(name,30);
 cout<<name<<endl;
 }
  entrada.close();
  }

int main()
{
char continuar;
  do
  {
  salida_datos_file();
    cout<<"\n\nDeseas registrar otro nombre (s/n) ==>";
    cin>>continuar;
  }
  while(continuar=='s' || continuar=='S');
  entrada_datos_file();
  getch();
  }





No hay comentarios:

Publicar un comentario