FAQ Database Discussion Community


Does not evaluating the expression to which sizeof is applied make it legal to dereference a null or invalid pointer inside sizeof in C++?

c++,language-lawyer,sizeof,undefined-behavior,null-pointer
First of all, I've seen this question about C99 and the accepted answer references operand is not evaluated wording in the C99 Standard draft. I'm not sure this answer applies to C++03. There's also this question about C++ that has an accepted answer citing similar wording and also In some...

Initializing Array of Pointers to nullpointer

c++,arrays,pointers,initialization,null-pointer
Hello stackover flow community, I'm trying initialize two empty array of pointers but getting this error on Visual Studio 2013: Unhandled exception at 0x011C5E9C in 45CProject.exe: 0xC0000005: Access violation writing location 0x00000000. Here is my code: #include <iostream> using namespace std; int main(){ int* a[10] = { nullptr }; int*...

Can I assume NULL value in comparison as the false?

c,pointers,comparison,condition,null-pointer
I know that NULL == (void *)0 but it is mentioned that it can be represented as a value which doesn't contain all zeros. What bothers me is if those pieces of code are equivalent for all (any_type *): any_type *val; if (val) { ... }; and if (val !=...

Null pointer exception in android sqlite

android,sqlite,exception,null-pointer
I am new to android I am creating an android application that consists of a registration dialog and sqlite storage.But here i was getting null pointer exception.I didn't find any mistake but it was showing null pointer exception.I have been trying this code since 2 hours Here i used custom...

How to use NULL in a .cpp file?

c++,null-pointer
I'm studying the only instance now(in c++), and I tried the following code in my .cpp file. #include "OnlyInstance.h" OnlyInstance* OnlyInstance::instance = NULL; .......... but the compiler told me "error C2065: 'NULL' : undeclared identifier". So is that means, I should #include <stdio.h> in front of it? But I also...