Past Source Code

I’ve been coding since 2002, so I have created a couple of programs. Well recently I have started coding in C++ because that’s what they teach us at my university so I’m going to mention some of the codes I have that are “working”. If you visit the site http://shinju.250free.com/coding you will see a couple of codes and zip files, well right now it’s a mess, but I have complete programs there.


Minesweeper (Buscaminas) Filename: bm1.zip and bm2.zip
Well the name says it all I guess. The code isn’t perfect, it has a couple of problems, I can’t list them all here, because the list could be very long, so let me just mention a couple of them ;-)
Who’s counting this? Well the program doesn’t know how to count correctly, you see, the numbers on the game mean a lot, they represent where and how many mines are around. When the program starts counting the mines it tends to replace the existing mines in the game.
How do you win again Winning should be simple, just uncover all the squares in the board except for the mines. But you see the program doesn’t know that, so what it does is simply count how many asterisks you have left, so if you have 10 asterisks left in your board, them being a mine or not, you will win. If you do hit a mine then you will loose the game, at least something works.

Ok, let’s move on to another program.

Directed Graphs (Digrafos) Filename: digrafos.cpp
This one was done for discrete math, it should allow the user to create a directed graph by just giving the coordinates. Since it’s in a console and there is no GUI [Graphical User Interface] you won’t see the graphs.
OK, now what’s wrong with this code? Well the code works, just one small bug has been spotted:
<strong>Hey what happened to my node?</strong> When you create a new node the program prints the list at the end so you can see where your new node is, the problem is that you won’t see the new node unless you add another node, so the last node will always be (0,0), the weird part is that when you add a new node you will see the last one that you type and not the new one. Now I’m guessing that this is because of the way the list is being handled. I guess this can be fixed by using a linked list.

Split function Filename: split.cpp
This code works without a problem, or at least I haven’t found one. The idea of this code is very simple, say you give the following string:

“Hello world, you there?”

Now it will ask you for a character, when the function finds this character it will split the string there and create an array with whatever was before that character, so let’s say the user inputs the character ‘o’, the code will print the following:

1. “Hell”
2. “w”
3. “rld, y”
4. “u there?”

Now if the user typed another character then it will do the same, but with that character that was typed.

Text Inverter (Invertir Texto) Filepath: exam3/pregunta3/
This code actually works, well as long as you don’t compile it on Visual C++ 6.0, that compiler is broken. The program opens a text file and inverts everything in that file, so the first word on the original file will be the last word on the copy.
So where’s the error? Well it’s simple, there’s a -1 missing in a declaration. Can’t remember the line right now. If you compile it in g++ in Linux it will work without any problems, but if you compile it on Visual C++ 6.0 it won’t invert the words just because of that -1, this is due to the fact that it copies the null (\0) or new line (\n) character as the first character in the new string, so anything beyond that is ignored therefore not printing that. So the solution is simple, in the main file (p3.cpp) look for the cycle that does this and add the -1.

There is more code there, but those are like the complete ones. Now one last thing before you start e-mailing me, the codes are written for my university projects, so the comments in them and what they print to the console are in Spanish, oh and they’re full of grammatical errors, like they’re missing the tilde where it goes. It’s not that I don’t know how to write in spanish, it’s that I don’t like writing in spanish ;-) .

-LMurillo

0 Responses to “Past Source Code”


  1. No Comments

Leave a Reply