Tuesday, January 30, 2007

Project 1, 100%

So I finished my project, which I don't believe is due until Thursday. Anyways, I went above and beyond and did all of the extra credit. It was really simple except I had some problems with strings.

Warning, programmer talk ahead!

This is my learning experience, it may one day help someone else.

When using BASIC style languages like darkBASIC, Visual Basic, and Gambas, strings are real easy to deal with. I'm not saying strings are hard in C++, they just don't work quite the way you would think they would. I'm talking about assignment. It's real easy to put a string literal into a character array in C++ when you declare it.

Something like this:

char string[10] = "my string";

Works well, no problems at all. You can even assign it some user input with the cin command.

cin >> string;

The problem is when you want to assign it with something specific. Normally, variables can be assigned this way:

int number;
number = 1;

The variable 'number' now has the value of 1. I figured I could do the same with strings.

string = "new string";

Oh no. You get an error saying you converted a char constant to a char. Yeah. This kind of approach works just fine in my basic style languages.

Me, being the stubborn jerk I am, decided not to ask my teacher about any of this stuff and to just figure it out on my own. I'd list other way's I tried but they are wrong and are of no use to anybody. Anyways, I found a site that showed me how to do it the right way. Hurray the internet!

strcpy(string, "new string");

Oy. That is the proper way of doing it. Not any more difficult than an assignment, just a pain because I didn't know it.

END PROGRAMMER TALK.

My project is done, and is cross-platform. It runs on Linux and Windows.

Thursday, January 25, 2007

First project of the semester

So it's week two and I finally got my first project in my C++ class.

It's done.

Well, almost done, I haven't quite gotten the extra credit worked out yet. I'm some what confused with how to use the 'or' operator in if statements yet. The code is all there, just the extra credit part is a bit buggy. It's commented out so it still runs fine.

The project itself is a simple console application (like msdos or the terminal if your not using windows). It takes your birthday and the current day and calculates "biorythms". Yeah, I don't understand what they are exactly. It works, that's all that's important, right? Anyways, project isn't due until next week, so I have plenty of time to fiddle around with it.

I forgot to mention. I had a genius idea for getting my laptops to work. I was going to install a live linux cd onto the harddrive and boot it like a live cd. Would have been lightweight and easy for them to handle. Only problem, one has a dead backup battery and the other has a bad cdrom. Soo, both are screwed...

Tuesday, January 23, 2007

Hardware

Well I'm back in school, this can only mean one thing! That's right! I'm coding again! This time it's c++.

Anyways, I attempted to give life to a couple of old friends of mine. They are laptops. Ones that I obtained for free. Anyways, they both have about 300mhz processing speed with 128megs of ram. Pretty old. I thought I could install a nice linux distribution on them and that they would be useful to me once again. Alas, I cannot get the one I want to install. Pretty frustrating. I was able to get "Damn Small Linux" to install on one. But since it was meant to be run from a pen drive, it had crap for applications. So instead of manually going and installing all the apps I wanted and wasting a bunch of time I decided that I would install a flavor of my favorite distribution, Ubuntu. It's called Xubuntu and is meant to be run on older systems. I downloaded the alt cd (it doesn't boot as a live cd because that's how old these machines are) and burned it. I began to install it but it freezes half way. Oh well, I'll try again with the other laptop later.

Oh well. On a lighter note, I installed a C++ IDE on my pendrive so that I can develop applications on the go! Wasn't very difficult, but I felt clever in discovering a very easy way to do it. My teacher said that it would be difficult and a pain in the ass. A classmate tried it and said it was a pain in the ass. I tried it and thought it was a pain in the ass until my programmer's logic kicked in with a, "wait! it has to write out to a config file!". Long story short, I was able to simplify the pain in the ass process by simply opening the config file in a text editor and using the replace all command. Easy peasy lemon squeezy! Only a slight pain.

My computer is still running great too! Although I had to reinstall my OS again a few weeks ago. Worth it to go back to GNOME.
Powered By Blogger