The length of the garlic guest string

Source: Internet
Author: User

String length

On the right we give a program that has been basically completed, read in a string, call a function called Str_len to calculate the length of the string, and output.

Smart you should have found that the function called Str_len is not completed, in the case of not modifying the function prototype, please complete the Str_len function, to achieve our above functions.

  1. Sample input
    Abcdefg
    Sample output
    7

    1#include <iostream>2 using namespacestd;3 4 intStr_len (Char*str);5 6 intMain () {7     Char*str =New Char[ -];8Cin>>str;9cout<<Str_len (str);Ten     Deletestr; One     return 0; A } -  - intStr_len (Char*str) { the //please complete your function here. -     intI=0; -      while(* (str+i)! =' /') -     { +i++; -     } +     returni; A}

The length of the garlic guest string

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.