I feel like my real first assignment in the Stanford 106B course was just getting a working compiler set up. There were library issues... it was a process. It really makes one value Python. Oh, I know C++ has its advantages over Python, but on the other hand, for the kind of programming, I doubt many if any of those advantages will be relevant. But whatever.
My first assignment completed, I move on to the first "true" assignment, which was the first one of problem set 1. This asked me to write a function that would remove select bits from a string. Here's what I came up with:
http://pastebin.com/K8c6qLb7
I initially wrote it with a cin command instead of fgets. This was OK but it crashed when I input a string with whitespace in it. I asked the good folks at my hangout openstudy.com about it, and they told me to use gets, but then another said that gets should be avoided in favor of fgets. So, that's what I used. My choice of 200 characters is quite arbitrary; I feel like it's long enough to incorporate most sentences so that's what I did. Anyway, it works. Here's an example output:
http://pastebin.com/aC2WXMFa
No comments:
Post a Comment