Is C++ Array passed by reference or by pointer?

At worst, your lecturer is wrong. At best, he was simplifying terminology, and confusing you in the process. This is reasonably commonplace in software education, unfortunately. The truth is, many books get this wrong as well; the array is not “passed” at all, either “by pointer” or “by reference”. In fact, because arrays cannot be passed by … Read more

C: How do I make a number always round up

First of all, you use the data type int, which cannot hold fractional values (and will implicitly round them towards zero, even before the function is ever called.) You should use double instead, since this is the proper datatype for fractional numbers. You would also want to use the ceil(x) function, which gives the nearest whole number larger than or … Read more

Difference between function arguments declared with & and * in C++

f2 is taking it’s arguments by reference, which is essentially an alias for the arguments you pass. The difference between pointer and reference is that a reference cannot be NULL. With the f you need to pass the address (using & operator) of the parameters you’re passing to the pointer, where when you pass by reference you just pass the parameters and … Read more

anchor jumping by using javascript

You can get the coordinate of the target element and set the scroll position to it. But this is so complicated. Here is a lazier way to do that: This uses replaceState to manipulate the url. If you also want support for IE, then you will have to do it the complicated way: Demo: http://jsfiddle.net/DerekL/rEpPA/Another … Read more