C++ IBM & EDX Lab: String Length and Pointers
Yesterday's lab and lesson were on pointers in C++. Below is an assignment from 1 of the labs. My submitted code is below. I will be posting the code to Github once the course was been archived. The assignment was about calculating a string length. However, we had to use a char pointer which made the task difficult. I started to appreciate Python's string methods. Lab: String Length Write a program to calculate the length of the string using a pointer. Get the input string from the user and pass this string to the function. Note: Please avoid the usage of exit(0) in your code. Implement the following methods. 1. implement ‘stringLength’ Method signature, int stringLength(char* str) In this method, the input string given by the user is passed as a parameter. Find the length of the input string using a pointer and return it. The char pointer(char *) is passed as an argument to this method. 2. implement ‘main’ Method signature, int main() ...