its like i understand it when you write it out .. its just i always mess up and get confused doing it alone.. i guess practice will make perfect.. thx
Was there a time when you were comfortable with the assignments? Was there a place when things stopped making sense? Do you need to re-read some notes or your book to cement earlier concepts? If you are given an assignment and have no idea where to even begin, your inability to complete the assignment is not the real problem. It is a symptom of the real problem of you not having a firm grasp on the material. Were there problems in earlier chapters that were not assigned that you can work through? Can the teacher provide you with small supplementary programming problems to help shore up your understanding?
When you read an assignment, can you break things down? You need to get the length of a C string. OK, have you done that before? If not, do you know what characteristics a C string has? How do you know when you've gotten to the end? How would you write strlen yourself if it wasn't available in the libraries? Once you have the length, how would you find the next multiple of 16 larger than that number? You could loop tracking multiples of 16 until this value is larger than the length you found. What if you found how many blocks of sixteen could fit into the length? How would you find that? A truncating/integer division could tell you that. Once you know how many sixteens fit into the length, you know you just need to be able to get one more block of sixteen into the capacity. So you just need to bump up what you found by one. OK, so now you have the number of sixteens you want your capacity to be. Good news, so now to get the total just multiply by sixteen. When it's all written out like that it seems a lot easier to think of it in terms of a loop, but once the logic is written out actually coding it is pretty straight-forward.
Are you solving the presented problems on paper first or trying to come up with code first? Are you able to write down steps you'd take to get a solution on paper? What if you wrote down a sample string:
My cat is the coolest cat on the block, and is really good at making pancakes.
So how would you figure out how long that is? Count each character? When do you stop? On paper you just stop at the end. In code you have to look for a null to know you're at the end, but otherwise the concept is the same. How would you find the next multiple of sixteen greater than the length? Do you just know what the next multiple of 16 is? What if you didn't? Well, you could write them out until you found one greater than your length. In code, this would be a loop. If you thought of just dividing by 16 that's fine, too.
I think you need to make an appointment with your instructor. They're not there to trick you and make you fail. You're responsible for your own success, but they can help, it's their job.
-Lee