This is an old revision of the document!
It works! I am so excited that my little program works! I guess it's not that big of a deal, but man, what a feeling!
What really helped me, and what I think I'm going to continue doing, is keeping a notebook of all the commands, what they do, and any epiphanies I have along the way. It really helps to have a physical copy of everything I did during each project. That being said, some of the things that I learned:
Hey,
Hey you
Guess What
My program worked.
I know, I'm shocked too.
There were a couple things that I'm a little confused/happy about:
I've also noticed that as my programs become longer and more complex they're starting to look more and more like abstract art. If you take a couple of steps back and squint your eyes it kind of looks like a children's drawing, but I digress.
**Things to Improve on**
//this is a variable
isn't really providing any context.
Ah-Ha Moments
fprintf(stdout, "%d %d %d %d", wish,you,were,here);
each of those values could be different, depending on what the variable are defined as. They're referred to in the order that they appear.
So, apparently minGW is much more forgiving than the compiler on Lab46 when it comes to format specifiers. Thanks Danny for helping me out, there!
Ah-Ha Moments
Edit:
Variable type | Format Specifier |
---|---|
char | %c |
int | %d or %i (%u for unsigned) |
float | %f |
I'm almost done with the dow0 project, I just have work in those pesky leap years. I think what I'm going to have to do is create another if/then statement and use the % operator. Editing on lab46 is really frustrating with my head-bangingly slow internet, so I'll have to test it out/implement it tomorrow.
So the dow0 project got done, there was much rejoicing to be had. I used an “or” operator (The pipe makes a comeback!)
Other than that there's not really much to say. This project was very similar to the last one so must of the stuff was pretty familiar. I have to say that the code, itself, looks a lot neater now (or maybe it doesn't, it looks better to me).
Uhh, I think my commenting has improved.
I'm kind of weary of using vim. Right now its this new scary thing but I should probably start getting more acquainted with it.
Ah-Ha Moments
Careful With That Compiler, Anita |
---|
[WRONG] gcc -o something.c name |
[WRONG] gcc name -o something.c |
[CORRECT] gcc -o name something.c |
The infamous “multiplying by eleven” project. I heard that this project was difficult due to the three digit numbers and the necessity to do it without loops. I expected to run into a lot of problems so I was pretty surprised the 3-digit part of my program worked without the need of a carry value. The code looked like
fd = ipt / 100; sd = (((ipt - 100) / 10) + fd); td = (((ipt - 100) % 10) + sd); ld = ((ipt - 100) % 10);
fprintf(stdout, “ Answer: %d%d%d%d”,fd,sd,td,ld); </code>
With int values fd,sd,td,and ld
representing the first, second, third, and last digits, respectively.
There was no need to send my findings to Old Pink, however, as I was actually inadvertently exploiting the rounding feature of the int type. Which is why I didn't need to carry, since the rounding took care of it for me.
I don't think that satisfies the project requirements, so I'm going to have to redo that part of the code. A cool little unexpected thing, like spotting an obscure Pink Floyd reference.
Ah-Ha Moments
So laziness got the best of me and I decided to leave my code the way it was. I tested it for 4, 5 and 6 digit numbers and it still works, which makes me think I did something wrong.
As for why it works: ¯\_(ツ)_/¯
I'm thinking that is has to do with the rounding, and just how the code is laid out. Another weird thing was my else if statement, that looked like
else if (99 <= ipt <= 999)
When I entered in numbers larger than 999 it still carried out that section of the code and it still worked. Not sure what was going on there, but I changed it just to make sure.
I haven't been able to successfully replicate the project using loops, so I'm working on getting more familiar with them. Getting better with vim, so that's cool.
So yeah, this project was super difficult for me. It was my first time actually using both typecasting and the argc, argv. That being said, I have a better idea of what they both mean. I still have to finish up my prime square root as well as my optimization, so I'll post more code-specific information once I get that done.
Loops are getting more familiar, I didn't think I would ever be able to embrace the for loop, but I'm definitely hooked now. Also its good to implement little “fprintf(stdout,” The value here is %d“,value); to get a snapshot or that the program is actually doing at that point. Many revelations were discovered using that.
After I got the logic of the nested loops down, I felt like I was doing pretty good. It's all about incrementing, and knowing exactly what you're incrementing and the effects it has. I broke out of my do while
loop habit, and I think I've converted to the for loop
camp. Funny enough, the biggest problem I had was getting the time value to display at the end of the output ( \n).
So here, I am, at 11:30 pm, I just test out everything on primerun
and I get MISMATCH.
huh, that's weird, I thought I checked like all the prime values. Long story short, I didn't and my output includes 989 (thanks, Eratosthenes) , which is not prime. I mean, I should have known when my opt program was like the easiest thing ever. My other programs also failed, but I'm not sure where, I checked the values up to 1,000 and it matched. Oh well.
What I learned/ Things to Improve On
i = 1973 do { i = i / 5; j++; } while ( i > 0)
i ≠ 1973 anymore.
I'm so close to getting the mbe1 project done! Unfortunately, I don't think its going to be before the midnight deadline, so no bonus points for me.
This project wasn't so bad, I think I'm getting arrays more. They're pretty cool, yo.
I thought I was going crazy when I kept seeing a `
in front of my array. I spent way more time than I'd like to admit googling its significance. Turns out it was just left there after the \n
, so it printed on the next line.
There is no Dark Side of the Moon, really. Matter of fact, its all dark.
So at first I was kind of taken aback by the whole “Linux thing” I'm a pretty faithful Windows user, and I was definitely missing my GUI that first day. However, my Network Fundamentals class that I took last semester kind of prepared me for using a CLI.
What I'm still struggling with is the Mercurial Repository. As of yet, still not a fan. I'm hoping that, like most things, it'll get easier with time.
Dear future Anita, When you get this:
abort: no repository found... (.hg not found) !
You tried to use an hg command (pull, push, commit, etc) while you weren't in the proper directory. That's like having your pudding before eating your meat. How can you have any pudding if you don't eat your meat?
Back to directories…
I'll be honest, I felt pretty cool when I was unscrambling those files and putting them together, like a digital paleontologist. Is it possible that there is a program that randomly tacs and revs files repeatedly to create a kind of encryption? I'll have to look into that. Oh and gzip compression options, I want to check that out, too.
What I Learned/ Ah-Ha Moments
Eureka! There are different levels of compression! Its amazing what you learn when you read the entire manual page! That being said, I'm really liking my decision to keep a notebook detailing the various commands and tips, it came in handy today.
The file tool is pretty cool, before this project I was wondering what was stopping me from giving a file whatever extension I wanted. Like, there's nothing stopping me from putting a
.wishyouwerehere
or
.anotherbrickinthewall
or even
.setthecontrolsfortheheartofthesun
extension. Yes, I tried it. Yes it worked
I don't know if I can handle this power. You win this round, Linux
What I Learned/ Ah-Ha Moments
I almost forgot about this week's entry. I like the Puzzlebox projects, and this one really upped the complexity; it was fun.
In other news, I finally got Ubuntu running on my virtual machine, so I've been playing around with that a little bit. I also tried out the default editor, vi. I had a momentary lapse of reason when I assumed it was vim. Don't think I'll do that again. I have to say, though, I really like Ubuntu, the fact that I don't have to load up putty every time I want to make changes to my repository is nice.
What I Learned/ Ah-Ha Moments
I'm still having trouble committing to the local, lab 46 repository, so I'll try to sort that out in the meantime.
So
Much
Time
I have spent an inane amount of time on the wpa project. That's okay, though, it was fun. I still have to add a few more pages and submit it, but I'm not too worried about doing that.
Then, magically, I finally figured out how to push and pull to the lab46 repository, it's been a life saver when it comes to not having to edit files online.
Who has two thumbs and finally completed their Web Page Adventure?
I just read through it and it is littered with typos and grammatical mistakes. Spellcheck is a lifesaver.
What I Learned
Much customization very wow.
I may have procrastinated a little bit on this one. Setting the path to home is just $HOME
right? Probably should ask…
I'm planning on doing some more reading into the config files and their options, they seem pretty neat.