LawyerMorty

Count letters in a string

Dec 8th, 2018
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.16 KB | None | 0 0
  1. int countString(char* str) {
  2.     int length = -1;
  3.     char letter = ' ';
  4.  
  5.     while (letter != '\0') {
  6.         length += 1;
  7.         letter = str[length];
  8.     }
  9.  
  10.     return length;
  11. }
Advertisement
Add Comment
Please, Sign In to add comment