could someone explain why i am getting this error when i am compiling the source using following g++ compiler
#include <cstdio>
#include <string>
using namespace std;
int main()
{
char source_language[50];
scanf("%16s\n",source_language);
int length = sizeof(source_language);
int sizeofchar = strlen(source_language);
printf("%d\n",sizeofchar);
}
this gives me following error
test.cpp: In function ‘int main()’:
test.cpp:31: error: ‘strlen’ was not declared in this scope
when i change the #include <string>
into #include <string.h>
or #include<cstring>
, it works fine, i need to figure out what is the difference using #include<string>
and #include<string.h>
. really appreciate any help