Question #3323

Write a program to find the length of a string manually.

Expert's answer

#include <iostream>
using namespace std;

int main()
{
char str[] = "hello";
char *it = str;
for (; *it; ++it);
int length = it - str;

cout << "The length of the string is " << length << endl;
return 0;
}
LATEST TUTORIALS
APPROVED BY CLIENTS