c++11 - c++ 14 vs 11 - sizeof return different value? -
for same program c++11 return 2 1 2, c++14 return 2 1 1 me. confused..
#include <iostream> #include <string> using namespace std; int main() { char a[2]; cout << sizeof(a) << endl; std::string b("a"); cout << b.size() << endl; char c[b.size() + 1]; cout << sizeof(c) << endl; return 0; }
char c[b.size() + 1];
not allowed in standard c++, version.
if find compiler accepts compiler extension, should consult documentation whichever compiler used.
Comments
Post a Comment