Life and Code

by Aditi Barbhai



How to find the length of an array in C


I think this is one of the most common questions that I see when I look through stackoverflow’s C section (and one that I myself struggled with after I first started learning C). C is not like Java. There are no dedicated functions to calculate the length of an array. You can’t even declare an array without first specifying the length (so C can allocate the appropriate amount of memory on the stack).

Anyway, but back to the question at hand: How do you find the length of an array in C? Continue reading “How to find the length of an array in C”

Divide and conquer your education

I was perusing one of the blogs I usually frequent today, and I came across this interesting “theory” on education that the author calls “The Cake Story”. It goes like this:

What you are about to learn is like a cake. A giant cake. It’s a knowledge cake. And you are given a tiny tiny spoon, for massive massive cake. Now here comes the best part. Somebody keeps slapping on stuff on the cake, new layers, more decoration (all eatable of course). It keeps getting bigger and bigger, faster and faster than you could eat it. How do you go about eating this giant cake? A spoonful at the time, right? But the way you eat it will define the whole experience, you just don’t know it.

Say there are two people, with a tiny spoon each. The first person takes a bit of the knowledge cake. This person is giddy, exited, about what has just been learned. The taste and effect is savored, motion is remembered. He or she shares this with everybody: “wow- look at what I can [do]. I can [eat] all this of this bite, and I will know all that when I take all those bites”.

The second person takes bite. Looks at the hole after the bite, then looks at the rest of the cake. Another layer is slapped on. The hole seems even smaller. The cake even bigger. The person thinks: “I know so little, and there is so much to learn. It’s impossible.”

… The second person [is] more likely to do worse and fail. The cake would win.

(some missing words filled in by me).

I think it’s an interesting way of approaching the success/failure rate of education based on the person’s attitude. No doubt, there is some truth to this. If you set out thinking “I am going to fail”, you will self-sabotage at some point and end up failing. Remember all those people telling you to “put out positive thoughts to the universe”? Well, they’re not completely off. Your attitude directly or indirectly affects the way you approach anything in life – be a problem, a relationship, or a new experience. If you set out with a “can do” attitude, you are less likely to get hung up on wonder “Can I do this???” and more likely to just push ahead and start searching for the solution. If you are constantly worried about your ability to do something, you will most likely never get to the point where you actually try doing whatever it is that you want to accomplish. As the quote goes “90% of success is just showing up”. Continue reading “Divide and conquer your education”

Blog at

Up ↑