find the length of char array in c++ code example
Example 1: c++ length of char*
#include
#include
using namespace std;
int main()
{
char *str = "ABC";
cout << strlen(str) << endl;
return 0;
}
Example 2: length of a char array in c
char chararray[10];
size_t len = strlen(chararray);
Example 3: how to find length of character array in c++
#include
using namespace std;
int main()
{
char arr[] = "grepper";
cout << sizeof(arr) << endl;
return 0;
// keep it in mind that character arrays have length of one more than your characters because last one is for \0 to show that word has ended
}