Errores extraños que inspiran ideas interesantes | C++

avatar

Buenas tardes, buen provecho para el que esté degustando su almuerzo mientras lee estas humildes líneas. Por acá vuelvo con un poco de programación, esta vez no seguiré la fórmula habitual porque el código de hoy tuvo resultados muy inusuales.

Good afternoon, bon appetit to whoever is having lunch while reading these humble lines. I'm back with a bit of programming, this time I won't follow the usual formula because today's code had very unusual results.


Portada.jpg

Png's de la película Spiderman, procedentes de una plantilla popular

Programación c++.png

Todo parte de una asignación que debo realizar para la universidad, en concreto, para una materia llamada "Estructura de datos". Esta es impartida con lenguaje C++, por lo que las publicaciones que he realizado por acá han sido geniales como modo de práctica, además claro de su aporte para otros estudiantes y su remuneración en cripto.

La asignación consta de 3 ejercicios, pero en concreto estuve enfocándome en uno que trataba de realizar un programa que permitiese guardar contactos telefónicos y luego registrarlos en un archivo que permitiese que nu se perdieran los datos luego de cerrar la consola. Ese enunciado me llevó a recordar una materia que vi hace ya casi 2 años, esta se titula "Taller de programación orientada a objetos". En ella realicé una agenda con funciones para buscar, agregar, modificar, eliminar y hasta listar de distintos modos los contactos registrados. Sin embargo, la funcionalidad de guardar con archivos no la dominé en su totalidad, el poco tiempo disponible sumado a las condiciones en las que cursé esa materia hicieron que no pudiesen alcanzar ese último escalón como hubiese querido.

Volviendo a mis respaldos de esas épocas, aproveché reciclar el código que en aquel tiempo tanto me había contado escribir, mi acceso a internet era más limitado que el de ahora por lo que una buena parte de las funciones nacieron del ensayo, error, análisis y consultas a los que llamaría veteranos de la universidad, es decir, algunos compañeros que iban más adelantados en sus semestres. Algo curioso que me sucedió mientras investigaba, fue que conseguí múltiples prototipos de agendas parecidas a la que me habían asignado en aquel 2020 tan agitado. De haber tenido mejor internet, quizás no hubiese sido tanto el estrés, aunque siendo positivos, será de ayuda para sobrellevar el futuro laboral.

It's all part of an assignment I have to do for university, specifically for a subject called "Data Structure". This is taught with C++ language, so the publications that I have made here have been great as a way of practice, in addition to its contribution to other students and their remuneration in crypto.

The assignment consists of 3 exercises, but in particular I was focusing on one that tried to make a program that would save phone contacts and then record them in a file that would not lose the data after closing the console. That statement led me to remember a subject that I saw almost 2 years ago, this one is called "Object Oriented Programming Workshop". In it I made an address book with functions to search, add, modify, delete and even list the registered contacts in different ways. However, I did not fully master the functionality of saving with files, the short time available and the conditions in which I took that subject meant that I could not reach that last step as I would have liked.

Going back to my backups of those times, I took advantage of recycling the code that at that time I had been so happy to write, my internet access was more limited than now so a good part of the functions were born of trial, error, analysis and consultation with what I would call veterans of the university, that is, some colleagues who were further ahead in their semesters. A curious thing that happened to me while researching was that I got multiple prototypes of agendas similar to the one I had been assigned in that hectic 2020. If I'd had better internet, maybe it wouldn't have been so stressful, although being positive, it will help me to cope with the future.

Programación c++.png

image.png

image.png

image.png

Programación c++.png

Entre los primeros intentos de que el código funcionase, cometí un par de errores en la búsqueda del porqué del estancamiento. Todas las vías que tomaba me llevaban a lo mismo, archivos inútiles que grababan mal la información y no la listaban. En una ocasión toqué por accidente el botón "bloq num", por lo que el teclado numérico de la derecha no iba a responder.

Como no me había dado cuenta, por mucho que tocaba esos números no se iban a colocar en la consola, por ello el programa no recibía las instrucciones del menú. Para ese instante pensé que se había dañado el sistema o era alguna mala jugada de Windows 10, pero no, había sido una novatada. Más adelante, habiendo logrado un pequeño registro me emocioné y me puse a probar algunas cosas en el código para lograr el listado y noté que el programa parecía ejecutarse pero se quedaba medio tildado. Luego revisé el archivo y vi algo que me sorprendió... Había creado un registro en un archivo .txt de 1,2 Gbs.

Por haber cometido un error en los bucles, estaba registrando campos con valores de espacios y variables longs = 0, una y otra vez. Acumulando así esa gigantezca cantidad de espacio para un txt. Fue tanto que el lector de ese tipo de archivos no podía abrirlo.

Between the first attempts to get the code to work, I made a couple of mistakes in the search for the reason for the deadlock. All the paths I took led me to the same thing, useless files that recorded the wrong information and didn't list it. On one occasion I accidentally hit the "Num Lock" button, so the numeric keypad on the right would not respond.

As I hadn't realised, no matter how much I touched those numbers, they wouldn't be placed on the console, so the program didn't receive the menu instructions. At that moment I thought that the system had been damaged or it was some bad move of Windows 10, but no, it had been a hazing. Later on, having achieved a little registration I got excited and started to try some things in the code to achieve the listing and noticed that the program seemed to run but it remained half-ticked. Then I checked the file and saw something that surprised me.... I had created a record in a 1.2 Gbs .txt file.

Because I had made a mistake in the loops, I was logging fields with values of spaces and variables longs = 0, over and over again. Thus accumulating that gigantic amount of space for a txt. It was so much that the file reader couldn't open it.

Programación c++.png

Xd.png

Programación c++.png

Luego de varias horas leyendo y probando código, además de repasar los videos que nos facilitó la profesora, encontré un canal que explicaba bastante bien el tema. Se llama "InformativaC", lleva un tiempo inactivo pero es una joya, explicaban bastante bien y gracias a una de sus series enfocada en la persistencia de datos, logré al fin conseguir un registro decente. Algo que les recomiendo cuando trabajen con archivos es ponerle excepciones a su antivirus, o se tornará bastante celoso por el hecho de que el código agrega archivos y los modifica.

Además, considerando lo que provocó aquel bucle erróneo, en cierto modo se pueden crear virus que saturen el disco duro de una pc, cosa que aunque se resolvería con borrar el archivo y ya, pues no dejaría de ser molesto. Incluso se podrían añadir opciones para ocultar el archivo y así ir mejorando su patrón de ataque. Pero bueno, eso por ahora es innecesario y sabiendo todo el tiempo que ya ha transcurrido pues una buena parte de los antivirus ya debe estar preparado para evitar ese tipo de virus.

After several hours reading and testing code, as well as reviewing the videos provided by the teacher, I found a channel that explained the subject quite well. It's called "InformativaC", it's been inactive for a while but it's a gem, they explained it quite well and thanks to one of their series focused on data persistence, I finally managed to get a decent log. One thing I recommend when working with files is to put exceptions on your antivirus, or it will become quite jealous of the fact that the code adds files and modifies them.

Also, considering what caused that erroneous loop, in a way you can create viruses that saturate the hard disk of a pc, something that although it would be solved by deleting the file and that's it, it would still be annoying. You could even add options to hide the file and thus improve its attack pattern. But well, that is unnecessary for now, and knowing all the time that has already passed, a good part of the antivirus should already be prepared to avoid this type of virus.

Programación c++.png

image.png

image.png

image.png

image.png

Programación c++.png

image.png

Captura del canal mencionado, Youtube

Programación c++.png

Bueno... Eso es todo compañeros, espero que este humilde contenido haya sido grato a su vista. Les deseo mucho éxito en su camino de aprendizaje diario.


Well... That's all folks, I hope this humble content has been pleasing to your eyes. I wish you much success in your daily learning journey.


Redes actualizada.gif


Puedes seguirme por acá si lo deseas:
You can follow me here if you want:

Cuenta secundaria
(Dibujos, edición y juegos) | Secondary account (Drawings, editing and games)



0
0
0.000
7 comments
avatar

Vaya archivo, saludos amigo.

0
0
0.000
avatar

Así es compañero, gracias por tomarte el tiempo de leer mis humildes líneas.

0
0
0.000
avatar

Es un bug serio. Al ser dañino podría calificar a malware, quizá a gusano (worm), pero no creo que a virus, pues no se reproduce. Interesante anécdota.

0
0
0.000
avatar

Sí, tienes razón, aún debo profundizar esos conceptos de seguridad informática. Saludos y gracias por pasarte por acá! :D

0
0
0.000
avatar

¡Felicitaciones!


Has sido votado por @entropia

Estás participando para optar a la mención especial que se efectuará el domingo 24 de abril del 2022 a las 8:00 pm (hora de Venezuela), gracias a la cual el autor del artículo seleccionado recibirá la cantidad de 1 HIVE transferida a su cuenta.

¡También has recibido 1 ENTROKEN! El token del PROYECTO ENTROPÍA impulsado por la plataforma Steem-Engine.


1. Invierte en el PROYECTO ENTROPÍA y recibe ganancias semanalmente. Entra aquí para más información.

2. Contáctanos en Discord: https://discord.gg/hkCjFeb

3. Suscríbete a nuestra COMUNIDAD y apoya al trail de @Entropia y así podrás ganar recompensas de curación de forma automática. Entra aquí para más información sobre nuestro trail.

4. Visita nuestro canal de Youtube.

Atentamente

El equipo de curación del PROYECTO ENTROPÍA

0
0
0.000