char* example = "Lorem ipsum dolor sit amet";
int length = strlen(example);
std::cout << length << '
'; // 26
Instead of sizeof() for finding the length of strings or character
arrays, just use strlen(string_name) with the header file
#include <cstring>
it's easier.
const char* Coffee = "Nescafe";
for(int i = 0; i < strlen(Coffee); i++)
{
std::cout << Coffee[i] << "
";
}
string strOne;
cin >> strOne;
string::size_type count = strOne.size();
char *x = new char[count]();
for (int i = 0; i < count; i++){
x[i] = strOne.at(i);
}
for (int i = 0; i < count; i++){
cout << x[i];
}