Dev - C++ - Ayuda con registros en el siguiente codigo

 
Vista:

Ayuda con registros en el siguiente codigo

Publicado por john (1 intervención) el 12/06/2014 06:30:19
como hago los registros en txt del siguiente codigo por favor

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#include <stdio.h>
#define PERSONAS 10
 
main(){
 
int i=0,j=0,cant;
char nombre[PERSONAS][20],apellido[PERSONAS][20],telefono[PERSONAS][12],direccion[PERSONAS][50],opcion='s';
char aux1[PERSONAS][20],aux2[PERSONAS][20],aux3[PERSONAS][12],aux4[PERSONAS][50];
printf("\n\t*========================================*\n");
printf("\t*                                        *\n");
printf("\t*             Agenda Telefonica          *\n");
printf("\t*            [Maximo 10 Contactos]       *\n");
printf("\t*========================================*\n\n");
 
while (opcion=='s'||opcion=='S'){
	printf("Cuantas personas desea agregar a la agenda?\n");
	scanf("%d",&cant);
	while (cant>PERSONAS)
		{
		printf("\n\t*****SOLO SE ADMITEN HASTA %d PERSONAS*****\n\n",PERSONAS);
		printf("¿Cuantas personas desea agregar a la agenda?\n");
		scanf("%d",&cant);
		}
	for (i=0; i<cant; i++)
		{
		printf("\nIntroduzca el NOMBRE de la persona %d: ",i+1);
		scanf("%s",nombre[i]);
		printf("Introduzca el APELLIDO de la persona %d: ",i+1);
		scanf("%s",apellido[i]);
		printf("Introduzca el TELEFONO de la persona %d: ",i+1);
		scanf("%s",telefono[i]);
		printf("Introduzca la DIRECCION de la persona %d: ",i+1);
		scanf("%s",direccion[i]);
		}
 
	printf("\n");
	printf("+----------------------------------------------------------------+\n");
	printf("|  NOMBRE\t  |  APELLIDO\t  |  TELEFONO\t  |  DIRECCION\t |\n");
	printf("|----------------------------------------------------------------|\n");
 
 
	for (j=0; j<(cant-1); j++){
		for(i=j+1; i<cant; i++){
			if(strcmp(nombre[j],nombre[i]) > 0){
				strcpy(aux1[j],nombre[j]);
				strcpy(nombre[j],nombre[i]);
				strcpy(nombre[i],aux1[j]);
 
				strcpy(aux2[j],apellido[j]);
				strcpy(apellido[j],apellido[i]);
				strcpy(apellido[i],aux2[j]);
 
				strcpy(aux3[j],telefono[j]);
				strcpy(telefono[j],telefono[i]);
				strcpy(telefono[i],aux3[j]);
 
				strcpy(aux4[j],direccion[j]);
				strcpy(direccion[j],direccion[i]);
				strcpy(direccion[i],aux4[j]);
			}
		}
	}
 
	for (i=0; i<cant; i++)
		{
		printf("|  %s\t  |",nombre[i]);
		printf("  %s\t  |",apellido[i]);
		printf(" %s\t  |",telefono[i]);
		printf("  %s  ",direccion[i]);
		printf("\n|----------------------------------------------------------------|");
		printf("\n");
		}
	printf("\nDesea agregar mas contactos? <s/n>\n");
	scanf("%s",&opcion);
	printf("<>-----------------------------------<>\n\n");
	}
}
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder