“error: assignment to expression with array type error” when I assign a struct field (C)

You are facing issue in because, in the LHS, you’re using an array type, which is not assignable. To elaborate, from C11, chapter §6.5.16 assignment operator shall have a modifiable lvalue as its left operand. and, regarding the modifiable lvalue, from chapter §6.3.2.1 A modifiable lvalue is an lvalue that does not have array type, […] You need to use strcpy() to copy … Read more

How do I declare a 2d array in C++ using new?

If your row length is a compile time constant, C++11 allows See this answer. Compilers like gcc that allow variable-length arrays as an extension to C++ can use new as shown here to get fully runtime-variable array dimension functionality like C99 allows, but portable ISO C++ is limited to only the first dimension being variable. Another efficient option is … Read more

Are vectors passed to functions by value or by reference in C++

In C++, things are passed by value unless you specify otherwise using the &-operator (note that this operator is also used as the ‘address-of’ operator, but in a different context). This is all well documented, but I’ll re-iterate anyway: You can also choose to pass a pointer to a vector (void foo(vector<int> *bar)), but unless you … Read more

“Notice: Undefined variable”, “Notice: Undefined index”, and “Notice: Undefined offset” using PHP

Notice: Undefined variable From the vast wisdom of the PHP Manual: Relying on the default value of an uninitialized variable is problematic in the case of including one file into another which uses the same variable name. It is also a major security risk with register_globals turned on. E_NOTICE level error is issued in case of working with uninitialized variables, however not … Read more

How to print elements in a vector c++

Your function declaration and definition are not consistent, you want to generate vector from Initialize, you can do: To print vector: Now you call: Don’t forget to change function definition of Initialize, Print to match the new signature I provided above. Also you are redefining a local variable v which shadows function parameter, you just … Read more