if (p = getPtr() != 0) is the same with if (p = (getPtr() != 0)) and should be if ((p = getPtr()) != 0). if (i = 1024) may be if (i == 1024).