Evaluate the string length and return the result (using the array name as the parameter)

Source: Internet
Author: User

[Cpp]/** Copyright and version statement of the program section * Copyright (c) 2012, student * All rightsreserved from computer College of Yantai University. * file name: fun. cpp * Author: Li Meng * Completion Date: July 15, December 19, 2012 * version: v1.0 * description of the task and solution section: * input Description: omitted * Problem description: omitted * program output: as follows */www.2cto.com # include <iostream> using namespace std; int astrlen (char str []); int main () {int num; cout <"enter a string: "<endl; char str [50]; gets (str); num = astrlen (str); cout <" String Length: "<num <endl; return 0;} int astrl En (char str []) {int I = 0, n = 0; while (str [I]! = 0) {I ++; n ++;} return I;} experience: I feel like using an array name as a parameter is similar to a pointer.

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.