Is this Good-bye? Part 2

Hi!!! After a goodnight’s sleep I feel awesome! And now I can continue this really long post! 

Now we move on to chapter 8: Strings and vectors


Ok we’ll talk more about C-strings and strings when I do my review for my final test. But a C-string is this primitive(I think) thing where you can store text and it turns out it’s an array for saving text. So to declare a C-string you declare a char array, like this:

char s[#];

So anyway if you ask me this is exactly the same as an array… What’s the diff? I’m confused. Gotta ask the prof or figure it out on the way.

The thing is that not only do we have C-strings but we also have Strings. C-strings are faster but not as convenient. Strings are a class so I understand this means they’re modern and guess what? They have like a ton of member functions that make our life easier!

Now in my notes we move on to vectors. I’ve never used them in an actual program yet but I am looking forward to it because they are extremely dynamic so the way I see it they’re fun!

Watch this video, this kid pretty much explains what’s on my notebook except for that member function pop_back. Weird.


Well if you didn’t feel like watching the video here’s how you declare a vector like so:


v is the number of my vector and where you see the # well you’re suppose to write the size you want there but if you don’t wanna you don’t have to. Oh did you know these thingies <> are called angular brackets? Yeah you probably did. Everyone was calling them thingies in class it was funny. It took me back to my high school days! Yeah the capacity of the vector is what it’s allocated to it!♥ The size is what is used.

Now in my notes we suddenly move to chapter 9! GASPS!!!!!!!!!!! I gotta finish reading chapter 8!!! Because the thing is that I kinda started reading it but I already knew a few things about strings and we didn’t need to know that much about vectors for lab 7 so I kipped it and read chapter 9 because I knew NOTHING about pointers and dynamic arrays. 

So What are pointers? Watch vid! :p

This one bored me though… lolololololol

pointer=variable that can hold address of another variable. The prof wants us to keep in mind that pointers are not difficult!

OMG so apparently there’s this function sleep(#) that makes the program sleep for # of seconds so cool haven’t used it yet this has nothing to do w/ pointers but it was on my notes~

O.k so for some reason we go back to vectors in my notes. Weird huh?

I have this question in my notebook. What is a template? So I just went to the cpluplus reference and this is what they told me: “Function templates are special functions that can operate with generic types. This allows us to create a function template whose functionality can be adapted to more than one type or class without repeating the entire code for each type.”

A vector is a class template. When you do the <int> you are instantiating it, providing a type. Initially the vector is empty. Vectors are similar to arrays but they start their life with no elements. No garbage! Yay!

Then here in my notes I have the exact same push_back thing the kid did on the video so I’m not gonna go over it again. Oh! But here’s another member function the kid didn’t cover! It’s sample.size() for when you wanna now the size of the vector kinda analogous to .length for strings! The size is never negative, just sayin’.

Bit pattern=representation of a value

unsigned int= all the bit patterns are used for post values. ***Not sure of what that means but it’s in my notebook lol.

This was on the video but remember: If you wanna use vectors DON’T forget to include #include <vector>

Oh and check this out:

if you do this vector<int> v; You have a vector of elements but if you do this:

vector<vector<int>> v; you have a vector with a lot of other vectors inside! This reminds me of Physics, lol.

Allocation of memory is costly… Hmm don’t know what he was referring with that…

Going back to pointers…(my notes are topsy-turvy)

dereference operator = * = take the address go there and use the variable at that address.

The value of pointers is always an address. The only way to store an address is in a pointer. Array parameter variables are pointers.

So there’s this thing called the delete operator with it you give up your rights to access the address the pointer was pointing to. Apparently after you delete a pointer you can’t do anything until you assign a fresh address. After deleting dereferencing is undefined.

A dangling pointer is a pointer that points to a dynamic variable that has been released.

There’s another thing, the new operator. Although I had been using it in lab 7 I feel like I hadn’t really gotten it until maybe now? O.k first you create the pointer like this, right?

MyType *myptr

But then you call it with new! Ok! I get what I was doing with new. Calling it! Like this:

myptr = new MyType

Anyway there’s this other weird thing that I don’t get very well, apparently these two things are the same:

d[i] and *(d+i)

BTW  in a for you can actually have two update actions, you just gotta separate them with a comma!

A for without an initialization or an update action is the same as a while!

When you have a weird thing that looks like this **r (two stars) that’s a pointer to a pointer. This *q[300] is a pointer static array. 

And finally all I wanna say is that the final test is on May 16th and that it looks super hard! The prof gave us a practice test I would like to discuss some of the questions here:

Question 1-b: Explain what a dangling pointer is. How do they occur? What is the danger they present? Earlier we said a dangling pointer is a pointer that points to a dynamic variable that has been released. They occur when you release a dynamic variable that had a pointer pointing to it. When you do this the pointer variable becomes undefined and so does the pointer. Undefined pointers are dangling pointers. The danger they present is that the pointer is now undefined and if you apply the dereferencing operator the result is unpredictable and often disastrous.

Question 2-a: C-strings and strings. How are they alike and how are they different. For each, describe scenarios in which it would be preferred over the other.


1. Sequences of characters

2. Similar functionality


1. The way they are stored. C-strings are stored in arrays, strings… I don’t know gotta ask prof…

2. C-strings are low level. Strings are more convenient.

3. C-strings take less time. Drawback of strings=there’s overhead on the operations. Extra work because of all the convenience they provide. They have to do checks and those take time. There’s a little bit of overhead in memory too.

***If time is important use a C-string if convenience is important use strings.

Question 2-b: Dynamic arrays and static arrays. How are they alike and how are they different?


1. Functionality

2. There can be pointer static arrays and dynamic arrays are alwasy done with pointers.


1. The static array has a fixed value at compile time. You can’t use a variable to contain the size. In any case you can use a constant for the size. With the dynamic array you can use a variable that way the user can decide the size of the array.

***Choose the static array when I know the size I want. I choose the dynamic array when the size is basically up to the user.

The other three questions on the practice final are programs that you have to explain or give the output.

As for my COJ adventures I ended up being able to complete a total of 7 problems!! YAAAAAAAAAAAAAAY!!! A lot more than expected but not enough AT ALL!!! Some kid did like 48!! I’m such a loser!! No matter I’ll do more problems during the summer but those won’t count as extra credit. Boo~~~~ Plus now all the ones left are the really hard ones. I gotta read them and see what happens. But no matter what I need to develop my thinking ability if I ever wanna be a boss programmer!!! YEAH!!!


Woooohohohoho!! Look at ME!!!!! I’m on 64 NOW!!! MUST BECOME AT LEAST 3!!!!!!!!! I ♥ COJ!!! But you know there are sooooooooooooooooooooooo many things that I need to do during this summer that we’ll just have to see how this goes. lol~~


So why is this good-bye? It’s not!! lololol!! It’s just that I wasn’t sure of what I would do with my blog after the class was over! But now the decision is as clear as day! I’ll keep it! I love this blog so I’ll continue to study with it!! Remember how I was studying chemistry? Well now I’m almost 100% sure that I’ll change to computer science and graduate with enough determination!!! I still need to see one of their counselors though… Uuuugh but the secretary at the math dept is always mean to me… lol. So yeah! I’ll try to write about the stuff I learn in my next comp science class and since it’s not for class credit I can go wild and write about other things. I guess what we’re saying good-bye to is the formalities of this blog and to an amazing class and to a REALLY REALLY STUPID semester!!! ROAR!!! You know around the beginning of May I realized that I wasted my entire semester being depressed over silly things and that that’s one of the reasons why I failed all my classes I shouldn’t have cared and continue to concentrate.. Urrr… I’m such a loser~ When I say fail all my classes I mean I’m seeing little opportunity to pass any classes with an A except Biology. That’s the only one I have an A in. I have an 88 on this if I don’t mess the final up I guess I could get an A? Will the COJ and competition extra credit save me???? I hope so!!!!!!!!!!!!! I want an A on this class and I wanted one in Organic Chemsitry too but uh yeah…… Don’t see how that will happen…. As for my other classes I now know that I suck and complain too much and I don’t stand a chance. Urrr 😦 I can’t believe I used to be 4.00 before I came here.. lol. I thought that I would be able to keep up here too……. Pffffffff. Well I hope I waste less time being depressed next semester and CONCENTRATE!! I’m more positive about next semester because I’ll be taking comp classes that get me all pumped to do what I have to do except that they make me depressed too when I can’t solve the problem at hand lol! But let’s not think about the negatives~~~ Well good-bye semester!!! I doubt you will be missed. My first semester here (The one before this one lol cause I’m basically new here lol) was a lot better and lot more fun!! 🙂


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s