Guest User

Untitled

a guest
Nov 18th, 2017
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.01 KB | None | 0 0
  1. #include <fstream>
  2. #include <conio.h>
  3. #include <stdio.h>
  4.  
  5. struct persona
  6. {
  7. char nombre[25];
  8. char direccion[25];
  9. char telefono[25];
  10. char correo[25];
  11. }contacto;
  12.  
  13. void ingresar();
  14. void mostrar();
  15.  
  16. void main()
  17. {
  18. int n;
  19. int salida = 0;
  20. do
  21. {
  22. system("cls");
  23. cout << "nn---M.E.N.U---nn";
  24. cout << "n1. Ingresar Contactosn";
  25. cout << "n2. Mostrar Contactosn";
  26. cout << "n3. Salirn";
  27. cout << "n_ ";
  28. cin >> n;
  29. switch (n)
  30. {
  31. case 1: ingresar(); break;
  32. case 2: mostrar(); break;
  33. case 3: salida = 1; break;
  34. default:
  35. clrscr();
  36. cout << "nnnPresione Solamente Una De Las Teclas Indicadas";
  37. cout << "nnnPresione Una Tecla Para Continuar...!";
  38. getch();
  39. break;
  40. }
  41. } while (salida == 0);
  42. getch();
  43. }
  44.  
  45. void ingresar()
  46. {
  47. int dec;
  48. clrscr();
  49. ofstream agenda;
  50. agenda.open("agenda.txt", ios::out | ios::app);
  51. if (agenda.fail())
  52. {
  53. cout << "Ocurrio un error al abrir el archivo";
  54. getch();
  55. }
  56. else
  57. {
  58. do {
  59. system("cls");
  60. cout << "nnIngrese Su Nombre: ";
  61. gets(contacto.nombre);
  62. cout << "nnIngrese su direccion:";
  63. gets(contacto.direccion);
  64. cout << "nnIngrese su Telefono: ";
  65. gets(contacto.telefono);
  66. cout << "nnIngrese su Correo Electronico: ";
  67. gets(contacto.correo);
  68. agenda << contacto.nombre << " " << contacto.direccion << " " << contacto.telefono << " " << contacto.correo << "nn";
  69. cout << "nn desea ingresar otro contacto a la agenda.? ";
  70. cout << "nn 1=si, 2=no n" << endl;
  71. cin >> dec;
  72. } while (dec == 1);
  73. }
  74. agenda.close();
  75. getch();
  76. }
  77.  
  78. void mostrar()
  79. {
  80. system("cls");
  81. cout << "n";
  82. ifstream agenda;
  83. agenda.open("agenda.txt");
  84. while (!agenda.eof())
  85. cout << (char)agenda.get();
  86. agenda.close();
  87. getch();
  88. }
Add Comment
Please, Sign In to add comment