/*******************************************************************************
* Aiden Stannard // CS1A // Chapter 10 Homework: Challange 1# // 11/28/2026
* _____________________________________________________________________________
*
* Length Finder
* _____________________________________________________________________________
*
* This program returns the length of a c-string from a given c-string.
* _____________________________________________________________________________
*
* Input: result = length(ptr);
*
* Output: The length of cString is__
*
******************************************************************************/
#include <iostream>
#include <cctype>
#include <cstring>
using namespace std;
int length(char *);
int main (){
char cString[] = "Hello"; // string definition and initialization
char *ptr = cString; // Defines pointer and initializes it to the CString
int result; // Stores function return value
result = length(ptr); // passes the pointer to the function "length"
cout << "The length of cString is " << result << endl; // outputs function
// return value to the console
return 0;
}
int length(char *ptr){
int y;
y = strlen(ptr); // strlen function finds the length of a string
return y;
}