Here is a collection of Java/C++ differences we have discovered so far in this class. If, while working on your projects (or even projects in other classes) you have learned of some other differences, please e-mail them to one of the TAs so that it can be included here. I can also include notes which are not specific to Java/C++ differences but just good notes to have when programming in C++. Perhaps some of you more experienced in C++ can add some of these.
Pointers are not initialized to NULL. Therefore, if you expect a pointer to be NULL at some point, you need to make sure that you have set it to NULL.
The following lines are (approximately) equivalent.
Therefore, if you intend for r to be the same node as nodes[i] which would occur automatically by typing the first line in Java, you must type the second line in C and use r as a pointer to nodes[i]. If you type
Division by 0 will not cause an exception in C. Therefore, if your program performs a divide by zero it will continue running until the result causes your code to crash likely somewhere far from the problem, thus making this difficult to debug.
Division by zero can often ocurr when dividing by a user entered value, normalizing a zero vector, normalizing a filter with weights summing to zero, ...
When using printf, it is necessary to use the correct type syntax for printing variables.
Examples:
int i = 3;
float x = 2.0;
char t[] = "Sziasztok világ!"
printf( "%d %f %s %c \n", i, x, t,   t[i]);