|
Mostrar Temas
|
Páginas: [1]
|
1
|
Programación / Java / Arreglo de inmuebles
|
en: 18 Febrero 2015, 21:30 pm
|
Hola, estoy haciendo un programa pero tengo un error en la implementación de mi código y no se cual es, lo que pasa es que escogiendo la opción 2(Mostrar Inmuebles), sale para cada inmueble el mismo propietario. Estas son las Clases import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class TestPropietario { private static Inmueble ArregloI[]=new Inmueble[5]; public static void Imprimir (int Pos ) throws IOException{ System. out. println("\nPropietario " + ArregloI [Pos ]. getMiPropietario(). getNombreCompleto() + ":\n"); System. out. println("Estado " + ArregloI [Pos ]. getEstado() + "\n"); } int Opcion=0; System. out. println("\n1. Ingresar un inmueble\n"); System. out. println("2. Mostrar Inmuebles\n"); System. out. println("3. Salir\n"); Capturar= Lector.readLine(); return Opcion; } int OpcionM=0, Cont=0; Propietario AuxProp= new Propietario(null, null); for(int i=0; i<5; i++) ArregloI[i]= new Inmueble(); while(OpcionM!=3){ OpcionM=MenuPrincipal(); switch(OpcionM){ case 1: System. out. println("Ingrese el Estado del Inmueble (Libre - Ocupado)"); Capturar= Lector.readLine(); Estado=Capturar; System. out. println("Ingrese el Nombre del Propietario"); Capturar= Lector.readLine(); AuxProp.setNombreCompleto(Capturar); System. out. println("Ingrese el numero de telefono del propietario"); Capturar= Lector.readLine(); AuxProp.setTelContac(Capturar); if(Cont<5){ ArregloI[Cont].Llenar(Estado, AuxProp); Cont+=1; } else System. out. println("Ha llegado al límite máximo de Inmuebles"); break; case 2: for(int i=0; i<5; i++) Imprimir(i); break; case 3: break; } } }
public class Propietario { private String NombreCompleto ; public Propietario (String nombreCompleto, String telContac ) { NombreCompleto = nombreCompleto; TelContac = telContac; } public String getNombreCompleto () { return NombreCompleto; } public void setNombreCompleto (String nombreCompleto ) { NombreCompleto = nombreCompleto; } public String getTelContac () { return TelContac; } public void setTelContac (String telContac ) { TelContac = telContac; } }
public class Inmueble { private Propietario MiPropietario=new Propietario(null, null); public void Llenar (String Estado, Propietario MiPropietario ){ setEstado(Estado); setMiPropietario(MiPropietario); } public Inmueble() { } return Estado; } public void setEstado (String estado ) { Estado = estado; } public Propietario getMiPropietario() { return MiPropietario; } public void setMiPropietario(Propietario miPropietario) { MiPropietario = miPropietario; } }
Verán, al momento ingresar a la opción 2 después de haber llenado 2 inmueble sale algo así:
|
|
|
2
|
Programación / Ingeniería Inversa / Desensamblado de un archivo binario
|
en: 26 Noviembre 2014, 03:00 am
|
Hola gente, gracias por leer mi post, primero que todo tengo un archivo desensamblado en codigo ensamblador y quisiera que me guiaran por donde empiezo para interpretar y lograr descifrar que es lo que hace el programa 08048424 <_init>: 8048424: 53 push %ebx 8048425: 83 ec 08 sub $0x8,%esp 8048428: e8 13 01 00 00 call 8048540 <__x86.get_pc_thunk.bx> 804842d: 81 c3 d3 1b 00 00 add $0x1bd3,%ebx 8048433: 8b 83 fc ff ff ff mov -0x4(%ebx),%eax 8048439: 85 c0 test %eax,%eax 804843b: 74 05 je 8048442 <_init+0x1e> 804843d: e8 6e 00 00 00 call 80484b0 <__gmon_start__@plt> 8048442: 83 c4 08 add $0x8,%esp 8048445: 5b pop %ebx 8048446: c3 ret
Desensamblado de la sección .plt:
08048450 <read@plt-0x10>: 8048450: ff 35 04 a0 04 08 pushl 0x804a004 8048456: ff 25 08 a0 04 08 jmp *0x804a008 804845c: 00 00 add %al,(%eax) ...
08048460 <read@plt>: 8048460: ff 25 0c a0 04 08 jmp *0x804a00c 8048466: 68 00 00 00 00 push $0x0 804846b: e9 e0 ff ff ff jmp 8048450 <_init+0x2c>
08048470 <printf@plt>: 8048470: ff 25 10 a0 04 08 jmp *0x804a010 8048476: 68 08 00 00 00 push $0x8 804847b: e9 d0 ff ff ff jmp 8048450 <_init+0x2c>
08048480 <inet_pton@plt>: 8048480: ff 25 14 a0 04 08 jmp *0x804a014 8048486: 68 10 00 00 00 push $0x10 804848b: e9 c0 ff ff ff jmp 8048450 <_init+0x2c>
08048490 <htons@plt>: 8048490: ff 25 18 a0 04 08 jmp *0x804a018 8048496: 68 18 00 00 00 push $0x18 804849b: e9 b0 ff ff ff jmp 8048450 <_init+0x2c>
080484a0 <puts@plt>: 80484a0: ff 25 1c a0 04 08 jmp *0x804a01c 80484a6: 68 20 00 00 00 push $0x20 80484ab: e9 a0 ff ff ff jmp 8048450 <_init+0x2c>
080484b0 <__gmon_start__@plt>: 80484b0: ff 25 20 a0 04 08 jmp *0x804a020 80484b6: 68 28 00 00 00 push $0x28 80484bb: e9 90 ff ff ff jmp 8048450 <_init+0x2c>
080484c0 <__libc_start_main@plt>: 80484c0: ff 25 24 a0 04 08 jmp *0x804a024 80484c6: 68 30 00 00 00 push $0x30 80484cb: e9 80 ff ff ff jmp 8048450 <_init+0x2c>
080484d0 <memset@plt>: 80484d0: ff 25 28 a0 04 08 jmp *0x804a028 80484d6: 68 38 00 00 00 push $0x38 80484db: e9 70 ff ff ff jmp 8048450 <_init+0x2c>
080484e0 <socket@plt>: 80484e0: ff 25 2c a0 04 08 jmp *0x804a02c 80484e6: 68 40 00 00 00 push $0x40 80484eb: e9 60 ff ff ff jmp 8048450 <_init+0x2c>
080484f0 <fputs@plt>: 80484f0: ff 25 30 a0 04 08 jmp *0x804a030 80484f6: 68 48 00 00 00 push $0x48 80484fb: e9 50 ff ff ff jmp 8048450 <_init+0x2c>
08048500 <connect@plt>: 8048500: ff 25 34 a0 04 08 jmp *0x804a034 8048506: 68 50 00 00 00 push $0x50 804850b: e9 40 ff ff ff jmp 8048450 <_init+0x2c>
Desensamblado de la sección .text:
08048510 <_start>: 8048510: 31 ed xor %ebp,%ebp 8048512: 5e pop %esi 8048513: 89 e1 mov %esp,%ecx 8048515: 83 e4 f0 and $0xfffffff0,%esp 8048518: 50 push %eax 8048519: 54 push %esp 804851a: 52 push %edx 804851b: 68 60 88 04 08 push $0x8048860 8048520: 68 f0 87 04 08 push $0x80487f0 8048525: 51 push %ecx 8048526: 56 push %esi 8048527: 68 10 86 04 08 push $0x8048610 804852c: e8 8f ff ff ff call 80484c0 <__libc_start_main@plt> 8048531: f4 hlt 8048532: 66 90 xchg %ax,%ax 8048534: 66 90 xchg %ax,%ax 8048536: 66 90 xchg %ax,%ax 8048538: 66 90 xchg %ax,%ax 804853a: 66 90 xchg %ax,%ax 804853c: 66 90 xchg %ax,%ax 804853e: 66 90 xchg %ax,%ax
08048540 <__x86.get_pc_thunk.bx>: 8048540: 8b 1c 24 mov (%esp),%ebx 8048543: c3 ret 8048544: 66 90 xchg %ax,%ax 8048546: 66 90 xchg %ax,%ax 8048548: 66 90 xchg %ax,%ax 804854a: 66 90 xchg %ax,%ax 804854c: 66 90 xchg %ax,%ax 804854e: 66 90 xchg %ax,%ax
08048550 <deregister_tm_clones>: 8048550: b8 43 a0 04 08 mov $0x804a043,%eax 8048555: 2d 40 a0 04 08 sub $0x804a040,%eax 804855a: 83 f8 06 cmp $0x6,%eax 804855d: 77 01 ja 8048560 <deregister_tm_clones+0x10> 804855f: c3 ret 8048560: b8 00 00 00 00 mov $0x0,%eax 8048565: 85 c0 test %eax,%eax 8048567: 74 f6 je 804855f <deregister_tm_clones+0xf> 8048569: 55 push %ebp 804856a: 89 e5 mov %esp,%ebp 804856c: 83 ec 18 sub $0x18,%esp 804856f: c7 04 24 40 a0 04 08 movl $0x804a040,(%esp) 8048576: ff d0 call *%eax 8048578: c9 leave 8048579: c3 ret 804857a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
08048580 <register_tm_clones>: 8048580: b8 40 a0 04 08 mov $0x804a040,%eax 8048585: 2d 40 a0 04 08 sub $0x804a040,%eax 804858a: c1 f8 02 sar $0x2,%eax 804858d: 89 c2 mov %eax,%edx 804858f: c1 ea 1f shr $0x1f,%edx 8048592: 01 d0 add %edx,%eax 8048594: d1 f8 sar %eax 8048596: 75 01 jne 8048599 <register_tm_clones+0x19> 8048598: c3 ret 8048599: ba 00 00 00 00 mov $0x0,%edx 804859e: 85 d2 test %edx,%edx 80485a0: 74 f6 je 8048598 <register_tm_clones+0x18> 80485a2: 55 push %ebp 80485a3: 89 e5 mov %esp,%ebp 80485a5: 83 ec 18 sub $0x18,%esp 80485a8: 89 44 24 04 mov %eax,0x4(%esp) 80485ac: c7 04 24 40 a0 04 08 movl $0x804a040,(%esp) 80485b3: ff d2 call *%edx 80485b5: c9 leave 80485b6: c3 ret 80485b7: 89 f6 mov %esi,%esi 80485b9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
080485c0 <__do_global_dtors_aux>: 80485c0: 80 3d 44 a0 04 08 00 cmpb $0x0,0x804a044 80485c7: 75 13 jne 80485dc <__do_global_dtors_aux+0x1c> 80485c9: 55 push %ebp 80485ca: 89 e5 mov %esp,%ebp 80485cc: 83 ec 08 sub $0x8,%esp 80485cf: e8 7c ff ff ff call 8048550 <deregister_tm_clones> 80485d4: c6 05 44 a0 04 08 01 movb $0x1,0x804a044 80485db: c9 leave 80485dc: f3 c3 repz ret 80485de: 66 90 xchg %ax,%ax
080485e0 <frame_dummy>: 80485e0: a1 08 9f 04 08 mov 0x8049f08,%eax 80485e5: 85 c0 test %eax,%eax 80485e7: 74 1f je 8048608 <frame_dummy+0x28> 80485e9: b8 00 00 00 00 mov $0x0,%eax 80485ee: 85 c0 test %eax,%eax 80485f0: 74 16 je 8048608 <frame_dummy+0x28> 80485f2: 55 push %ebp 80485f3: 89 e5 mov %esp,%ebp 80485f5: 83 ec 18 sub $0x18,%esp 80485f8: c7 04 24 08 9f 04 08 movl $0x8049f08,(%esp) 80485ff: ff d0 call *%eax 8048601: c9 leave 8048602: e9 79 ff ff ff jmp 8048580 <register_tm_clones> 8048607: 90 nop 8048608: e9 73 ff ff ff jmp 8048580 <register_tm_clones> 804860d: 66 90 xchg %ax,%ax 804860f: 90 nop
08048610 <main>: 8048610: 55 push %ebp 8048611: 89 e5 mov %esp,%ebp 8048613: 83 e4 f0 and $0xfffffff0,%esp 8048616: 81 ec 30 04 00 00 sub $0x430,%esp 804861c: c7 84 24 2c 04 00 00 movl $0x0,0x42c(%esp) 8048623: 00 00 00 00 8048627: c7 84 24 28 04 00 00 movl $0x0,0x428(%esp) 804862e: 00 00 00 00 8048632: 83 7d 08 02 cmpl $0x2,0x8(%ebp) 8048636: 74 1f je 8048657 <main+0x47> 8048638: 8b 45 0c mov 0xc(%ebp),%eax 804863b: 8b 00 mov (%eax),%eax 804863d: 89 44 24 04 mov %eax,0x4(%esp) 8048641: c7 04 24 80 88 04 08 movl $0x8048880,(%esp) 8048648: e8 23 fe ff ff call 8048470 <printf@plt> 804864d: b8 01 00 00 00 mov $0x1,%eax 8048652: e9 8c 01 00 00 jmp 80487e3 <main+0x1d3> 8048657: c7 44 24 08 00 04 00 movl $0x400,0x8(%esp) 804865e: 00 804865f: c7 44 24 04 30 00 00 movl $0x30,0x4(%esp) 8048666: 00 8048667: 8d 44 24 28 lea 0x28(%esp),%eax 804866b: 89 04 24 mov %eax,(%esp) 804866e: e8 5d fe ff ff call 80484d0 <memset@plt> 8048673: c7 44 24 08 00 00 00 movl $0x0,0x8(%esp) 804867a: 00 804867b: c7 44 24 04 01 00 00 movl $0x1,0x4(%esp) 8048682: 00 8048683: c7 04 24 02 00 00 00 movl $0x2,(%esp) 804868a: e8 51 fe ff ff call 80484e0 <socket@plt> 804868f: 89 84 24 2c 04 00 00 mov %eax,0x42c(%esp) 8048696: 83 bc 24 2c 04 00 00 cmpl $0x0,0x42c(%esp) 804869d: 00 804869e: 79 16 jns 80486b6 <main+0xa6> 80486a0: c7 04 24 a0 88 04 08 movl $0x80488a0,(%esp) 80486a7: e8 f4 fd ff ff call 80484a0 <puts@plt> 80486ac: b8 01 00 00 00 mov $0x1,%eax 80486b1: e9 2d 01 00 00 jmp 80487e3 <main+0x1d3> 80486b6: c7 44 24 08 10 00 00 movl $0x10,0x8(%esp) 80486bd: 00 80486be: c7 44 24 04 30 00 00 movl $0x30,0x4(%esp) 80486c5: 00 80486c6: 8d 44 24 18 lea 0x18(%esp),%eax 80486ca: 89 04 24 mov %eax,(%esp) 80486cd: e8 fe fd ff ff call 80484d0 <memset@plt> 80486d2: 66 c7 44 24 18 02 00 movw $0x2,0x18(%esp) 80486d9: c7 04 24 88 13 00 00 movl $0x1388,(%esp) 80486e0: e8 ab fd ff ff call 8048490 <htons@plt> 80486e5: 66 89 44 24 1a mov %ax,0x1a(%esp) 80486ea: 8b 45 0c mov 0xc(%ebp),%eax 80486ed: 83 c0 04 add $0x4,%eax 80486f0: 8b 00 mov (%eax),%eax 80486f2: 8d 54 24 18 lea 0x18(%esp),%edx 80486f6: 83 c2 04 add $0x4,%edx 80486f9: 89 54 24 08 mov %edx,0x8(%esp) 80486fd: 89 44 24 04 mov %eax,0x4(%esp) 8048701: c7 04 24 02 00 00 00 movl $0x2,(%esp) 8048708: e8 73 fd ff ff call 8048480 <inet_pton@plt> 804870d: 85 c0 test %eax,%eax 804870f: 7f 16 jg 8048727 <main+0x117> 8048711: c7 04 24 c3 88 04 08 movl $0x80488c3,(%esp) 8048718: e8 83 fd ff ff call 80484a0 <puts@plt> 804871d: b8 01 00 00 00 mov $0x1,%eax 8048722: e9 bc 00 00 00 jmp 80487e3 <main+0x1d3> 8048727: c7 44 24 08 10 00 00 movl $0x10,0x8(%esp) 804872e: 00 804872f: 8d 44 24 18 lea 0x18(%esp),%eax 8048733: 89 44 24 04 mov %eax,0x4(%esp) 8048737: 8b 84 24 2c 04 00 00 mov 0x42c(%esp),%eax 804873e: 89 04 24 mov %eax,(%esp) 8048741: e8 ba fd ff ff call 8048500 <connect@plt> 8048746: 85 c0 test %eax,%eax 8048748: 79 16 jns 8048760 <main+0x150> 804874a: c7 04 24 dd 88 04 08 movl $0x80488dd,(%esp) 8048751: e8 4a fd ff ff call 80484a0 <puts@plt> 8048756: b8 01 00 00 00 mov $0x1,%eax 804875b: e9 83 00 00 00 jmp 80487e3 <main+0x1d3> 8048760: eb 36 jmp 8048798 <main+0x188> 8048762: 8d 54 24 28 lea 0x28(%esp),%edx 8048766: 8b 84 24 28 04 00 00 mov 0x428(%esp),%eax 804876d: 01 d0 add %edx,%eax 804876f: c6 00 00 movb $0x0,(%eax) 8048772: a1 40 a0 04 08 mov 0x804a040,%eax 8048777: 89 44 24 04 mov %eax,0x4(%esp) 804877b: 8d 44 24 28 lea 0x28(%esp),%eax 804877f: 89 04 24 mov %eax,(%esp) 8048782: e8 69 fd ff ff call 80484f0 <fputs@plt> 8048787: 83 f8 ff cmp $0xffffffff,%eax 804878a: 75 0c jne 8048798 <main+0x188> 804878c: c7 04 24 f7 88 04 08 movl $0x80488f7,(%esp) 8048793: e8 08 fd ff ff call 80484a0 <puts@plt> 8048798: c7 44 24 08 ff 03 00 movl $0x3ff,0x8(%esp) 804879f: 00 80487a0: 8d 44 24 28 lea 0x28(%esp),%eax 80487a4: 89 44 24 04 mov %eax,0x4(%esp) 80487a8: 8b 84 24 2c 04 00 00 mov 0x42c(%esp),%eax 80487af: 89 04 24 mov %eax,(%esp) 80487b2: e8 a9 fc ff ff call 8048460 <read@plt> 80487b7: 89 84 24 28 04 00 00 mov %eax,0x428(%esp) 80487be: 83 bc 24 28 04 00 00 cmpl $0x0,0x428(%esp) 80487c5: 00 80487c6: 7f 9a jg 8048762 <main+0x152> 80487c8: 83 bc 24 28 04 00 00 cmpl $0x0,0x428(%esp) 80487cf: 00 80487d0: 79 0c jns 80487de <main+0x1ce> 80487d2: c7 04 24 0d 89 04 08 movl $0x804890d,(%esp) 80487d9: e8 c2 fc ff ff call 80484a0 <puts@plt> 80487de: b8 00 00 00 00 mov $0x0,%eax 80487e3: c9 leave 80487e4: c3 ret 80487e5: 66 90 xchg %ax,%ax 80487e7: 66 90 xchg %ax,%ax 80487e9: 66 90 xchg %ax,%ax 80487eb: 66 90 xchg %ax,%ax 80487ed: 66 90 xchg %ax,%ax 80487ef: 90 nop
080487f0 <__libc_csu_init>: 80487f0: 55 push %ebp 80487f1: 57 push %edi 80487f2: 31 ff xor %edi,%edi 80487f4: 56 push %esi 80487f5: 53 push %ebx 80487f6: e8 45 fd ff ff call 8048540 <__x86.get_pc_thunk.bx> 80487fb: 81 c3 05 18 00 00 add $0x1805,%ebx 8048801: 83 ec 1c sub $0x1c,%esp 8048804: 8b 6c 24 30 mov 0x30(%esp),%ebp 8048808: 8d b3 04 ff ff ff lea -0xfc(%ebx),%esi 804880e: e8 11 fc ff ff call 8048424 <_init> 8048813: 8d 83 00 ff ff ff lea -0x100(%ebx),%eax 8048819: 29 c6 sub %eax,%esi 804881b: c1 fe 02 sar $0x2,%esi 804881e: 85 f6 test %esi,%esi 8048820: 74 27 je 8048849 <__libc_csu_init+0x59> 8048822: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 8048828: 8b 44 24 38 mov 0x38(%esp),%eax 804882c: 89 2c 24 mov %ebp,(%esp) 804882f: 89 44 24 08 mov %eax,0x8(%esp) 8048833: 8b 44 24 34 mov 0x34(%esp),%eax 8048837: 89 44 24 04 mov %eax,0x4(%esp) 804883b: ff 94 bb 00 ff ff ff call *-0x100(%ebx,%edi,4) 8048842: 83 c7 01 add $0x1,%edi 8048845: 39 f7 cmp %esi,%edi 8048847: 75 df jne 8048828 <__libc_csu_init+0x38> 8048849: 83 c4 1c add $0x1c,%esp 804884c: 5b pop %ebx 804884d: 5e pop %esi 804884e: 5f pop %edi 804884f: 5d pop %ebp 8048850: c3 ret 8048851: eb 0d jmp 8048860 <__libc_csu_fini> 8048853: 90 nop 8048854: 90 nop 8048855: 90 nop 8048856: 90 nop 8048857: 90 nop 8048858: 90 nop 8048859: 90 nop 804885a: 90 nop 804885b: 90 nop 804885c: 90 nop 804885d: 90 nop 804885e: 90 nop 804885f: 90 nop
08048860 <__libc_csu_fini>: 8048860: f3 c3 repz ret 8048862: 66 90 xchg %ax,%ax
Desensamblado de la sección .fini:
08048864 <_fini>: 8048864: 53 push %ebx 8048865: 83 ec 08 sub $0x8,%esp 8048868: e8 d3 fc ff ff call 8048540 <__x86.get_pc_thunk.bx> 804886d: 81 c3 93 17 00 00 add $0x1793,%ebx 8048873: 83 c4 08 add $0x8,%esp 8048876: 5b pop %ebx 8048877: c3 ret
Como pueden ver el codigo es algo extenso pero esta como que dividido en partes y además contiene estos subtítulos Desensamblado de la sección .plt Desensamblado de la sección .text Desensamblado de la sección .fini Tambien hay que analizar estos para entender el programa??
|
|
|
4
|
Programación / Programación C/C++ / Duda LECTURA ARCHIVOS BINARIOS
|
en: 11 Mayo 2014, 20:01 pm
|
Buen Día, mi duda es acerca de la lectura de archivos Binarios, este es el código: void CargarInformacion(struct TNodo<Usuarios> **Lista) { struct Usuarios Load; ifstream Datos("Base De Datos.dat", ios::binary); if (Datos.good()) while (!Datos.eof()) if ( Datos.read((char*)&Load, sizeof(Load)) ) InsertarFinal(Lista, Load); Datos.close(); }
La Funcion funciona!!! pero no se por que hay que colocar estoDatos.read((char*)&Load, sizeof(Load))
dentro de un if, le pregunte a alguien pero me dice que es para que no lea 2 veces lo mismo, pero esa es la duda... por que????Gracias por su tiempo.
|
|
|
5
|
Programación / Programación C/C++ / Realmente extraño problema con cin.getline
|
en: 11 Abril 2014, 01:13 am
|
Hola Buenas, el problema es que en mi código en la LINEA 20,cin.getline pasa de largo y no ejecuta la instrucción de leer, ya he depurado el código con Dev C++ pero es realmente extraño. El error ÚNICAMENTE SUCEDE al escoger primero la opción 2 y después intentar con la 1. Aquí esta la porción de código. while (Opcion!=3) { cout<<"Menu Principal\n\n"; cout<<"1. Ingresar a Facebook"; cout<<"2. Crear una cuenta"<<endl; cout<<"3. Salir\n\n\n"; CharOp=getch();//Lee un caracter sin presionar enter y sin mostrarlo en pantalla if (CharOp=='1') { Opcion=1;//Se Decrara para mantener la condicion while principal system("cls"); Intentos=0; while (Intentos!=3) { gotoxy(30,10);cout<<"Usuario: "; cin.getline(User,10,'\n'); Validacion=BuscarLista(&ListaUsuarios, User, 1);//Validacion Se Encarga de ver si el Usuario Existe, if ( Validacion==false ) { gotoxy(39,12);cout<<"ID no encontrada!!!"<<endl; Sleep(1500); //Borra Los Espacios Incorrectos Para Un Nuevo Intento gotoxy(39,10);cout<<" "; gotoxy(39,12);cout<<" "; gotoxy(28,10);textcolor(12);cout<<char(219); Intentos+=1; } else Intentos=3; } } if (CharOp=='2') { Opcion=2;//Se Decrara para mantener la condicion while principal cout<<"Nombre: "; cin.getline(CuentaNueva.Nombre, 20,'\n'); cout<<"ID: "; cin.getline(CuentaNueva.ID, 10,'\n'); cout<<"Contrase"<<char(164)<<"a: "; cin.getline(CuentaNueva.Contrasenia, 10,'\n'); cout<<"Genero (M - F): ";//AQUI ESTA EL ERROR???? cin>>CuentaNueva.Genero; cout<<"Edad: "; cin>>CuentaNueva.Edad; cout<<"Documento: "; cin>>CuentaNueva.Documento; InsertarFinal(&ListaUsuarios, CuentaNueva); } if (CharOp=='3') Opcion=3;//Se Decrara para mantener la condicion while principal system("cls"); }
Si no me hago entender por favor descarguen el ejecutable https://mega.co.nz/#!Btx2URJb!Dsr7oOEZx5RfvQkVlEAAv5gSw40uD2FEw-Uxh1mQJ9IAqui el link del codigo https://mega.co.nz/#!owZQHZjB!QLbJo-EUYFfucYX2Mnn2GoBqzA56PLwqa1BYo4996Fs
|
|
|
6
|
Programación / Programación C/C++ / Duda Manejo De Archivos De Acceso Aleatorio
|
en: 31 Marzo 2014, 20:28 pm
|
La duda es que tengo un archivo de texto asi:
Lucas Gnneco Omar Rodriguez Laura Monroy
y lo que quiero es que atravez del manejo de archivos sin sobreescribir nada meter un nombre por ejemplo entre Omar y Laura.
Lucas Gnneco Omar Rodriguez Pepito Perez Laura Monroy
con acceso secuencial no me funciono, asi que creo que es con acceso aleatorio con seekg y seekp pero la verdad no he podido, podria alguien orientarme por favor.
|
|
|
7
|
Programación / Programación C/C++ / Asesoria Memoria Dinamica
|
en: 11 Marzo 2014, 21:59 pm
|
Hola, estoy haciendo un programa para contar el numero de palabras que tenga una frase, el problema es que por supuesto siempre el numero de palabras varia, por lo que segun pienso yo, hay que usar memoria dinamicaint main(int argc, char *argv[]) { char Lectura[200], *PTok, **Palabras=NULL; int i=0, j=0, ContPal=1; cin.getline(Lectura, sizeof(Lectura)); PTok=strtok(Lectura," "); while ( PTok!= NULL ) { AgrEspacio(Palabras, ContPal);//AgrEspacio Agrega Una Fila De Mas A Palabras strcpy( Palabras[i], PTok ); PTok=strtok(NULL," "); i+=1; ContPal+=1; } for ( j=0; j<i; j++ ) cout<<Palabras[j]<<endl; system("PAUSE"); return EXIT_SUCCESS; }
El problema como tal es esa funcion para agregar una fila a la matriz, ya que si compila, pero estoy violando el acceso a la memoria en una parte del codigo de esa funcion
void AgrEspacio ( char **Palabras, int NumPal) { char **TemFilas=new char*[NumPal]; for ( int i=0; i<NumPal; i++ ) { TemFilas[i]=new char[200]; TemFilas[i]=Palabras[i]; } Palabras=TemFilas; }
La verdad este tema de memoria dinamica se me hace un poco dificil de entender, ya que no se bien cuando es correcto usarla, por ejemplo en este ejercicio podria haber creado una matriz estatica como char Palabras[100][200];
en vez de pensar en memoria dinamica, pero la ventaja es que con esta voy agregando filas a mi matriz cuando lo voy necesitando en vez de declarar una estatica y ocupar memoria que tal vez no usareGracias por su tiempo.
|
|
|
8
|
Programación / Programación C/C++ / Problema Con Un Arreglo Dinamico [?]
|
en: 16 Octubre 2013, 01:31 am
|
El codigo compila pero el ejecutable no funciona tal como la imagen de el link #include <cstdlib> #include <iostream> using namespace std; struct Item{ int Peso; int Volumen; string Nombre; }; struct Maleta{ int Peso; int Volumen; int Cantidad_Items; Item *Items; }; int main(int argc, char *argv[]) { Maleta *Mi_Maleta=new Maleta[10]; Mi_Maleta->Items=new Item[10]; Mi_Maleta[1].Items[0].Nombre="Peras"; Mi_Maleta[1].Items[0].Volumen=12; Mi_Maleta[1].Items[0].Peso=16; system("PAUSE"); return EXIT_SUCCESS; }
http://www.subirimagenes.com/imagen-imagen1-8658261.html
|
|
|
9
|
Programación / Programación C/C++ / Asignar Mas Memoria A Un Arreglo Dinamico
|
en: 2 Septiembre 2013, 22:36 pm
|
En el main tengo un arreglo de tamaño 1 pero necesito que este incremente su tamaño a medida que el usuario digite mas y mas datos... #include <cstdlib> #include <iostream> #include <string> #include <conio.h>
using namespace std;
struct Datos { string Nombre; int Edad; };
struct Categorias { string Deporte; int Atletas; Datos Informacion; };
void Ingresar_Deportista ( Categorias *Deportes, int Cant_Deportes );
int main(int argc, char *argv[]) { int Num_Deportes=1; //Tamaño Variable - Cambia En Tiempo De Ejecucion Categorias *Deportes= new Categorias[Num_Deportes];
Ingresar_Deportista( Deportes, Num_Deportes ); system("PAUSE"); return EXIT_SUCCESS; }
Ese incremento de tamaño lo implemente en la funcion Ingresar_Deportista justo al final void Ingresar_Deportista ( Categorias *Deportes, int Cant_Deportes ){ int i=0, Aux=0; char Opcion='s'; while(Opcion=='s'){ cout<<"Deporte: "; cin>>Deportes[i].Deporte; cout<<"\nNombre: "; cin>>Deportes[i].Informacion.Nombre; cout<<"Edad: "; cin>>Deportes[i].Informacion.Edad; cout<<"\nIngresar Mas? Si(s) "; Opcion=getch(); i+=1; system("cls"); //Si Supera El Tamaño Maximo (Darle Mas Memoria Al Arreglo Dinamico)
if( i>=Cant_Deportes ){ Categorias *Agrandar= new Categorias[Cant_Deportes+1]; for(Aux=0; Aux<Cant_Deportes; Aux++) Agrandar[Aux]=Deportes[Aux]; Deportes=Agrandar;} } }
El codigo compila pero despues de ingresar el tercer deporte el ejecutable se totea, a que se debe esto?
|
|
|
10
|
Programación / Programación C/C++ / Problema Con Un Arreglo Dinamico De Estructuras [?]
|
en: 2 Septiembre 2013, 18:56 pm
|
#include <cstdlib> #include <iostream>
using namespace std;
struct Datos { char *Nombre; int Edad; };
struct Categorias { char *Deporte; int Atletas; Datos *Informacion; };
int main(int argc, char *argv[]) { Categorias *Otro= new Categorias[10]; Otro[0].Informacion->Nombre="Oscar"; system("PAUSE"); return EXIT_SUCCESS; }
Pordrian por favor ayudarme .. el codigo compila pero el ejecutable se totea
|
|
|
|
|
|
|