'not declared in this scope' when using strlen()
You forgot to include <cstring>
or <string.h>
.
cstring
will give you strlen
in the std
namespace, while string.h
will keep it in the global namespace.
You need to include cstring
header for strlen
:
#include <cstring>
you could alternatively include string.h
and that would put strlen
in the global namespace as opposed to std
namespace. I think it is better practice to use cstring
and to drop using using namespace std
.