What does malloc(0) return? [duplicate]

Others have answered how malloc(0) works. I will answer one of the questions that you asked that hasn’t been answered yet (I think). The question is about realloc(malloc(0), 0): What does malloc(0) return? Would the answer be same for realloc(malloc(0),0)? The standard says this about realloc(ptr, size): if ptr is NULL, it behaves like malloc(size), … Read more

How do you ‘realloc’ in C++?

Use ::std::vector! Type* t = (Type*)malloc(sizeof(Type)*n) memset(t, 0, sizeof(Type)*m) becomes ::std::vector<Type> t(n, 0); Then t = (Type*)realloc(t, sizeof(Type) * n2); becomes t.resize(n2); If you want to pass pointer into function, instead of Foo(t) use Foo(&t[0]) It is absolutely correct C++ code, because vector is a smart C-array.

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)