Does anyone know why Visual Studio is the only compiler to giving me this error - Expression must have a constant value (referring to size).
#include
The strlen function is not declared as constexpr, which means that the result of it is not a constant expression.
So size is not a constant expression and therefore it cannot be used as an array dimension. The code is ill-formed in Standard C++.
Many compilers have an extension that non-constant expressions may be used as an array dimension. If another compiler accepts this code then that would probably be the explanation. You might be able to prod the other compilers by using standards-compliance switches (e.g. for gcc, -std=c++14 -pedantic).
To work around this you could write your own constexpr equivalent to strlen; or you could use sizeof. Alternatively you could use std::string and avoid C-style string handling entirely.