CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Apr 2013
    Posts
    42

    length of a string

    Does anyone know a way to get the length of a string? I have tried:

    str.length
    str.size
    strlen()

    Bob

    Code:
    // Exercise in string manipulation
    
    #include <iostream>
    #include <string>
    
    void prtname(std::string str);
    
    using namespace std;
    
    int main()
    {
    	string input;
    
    	cout << "Please enter the name of a bird with long legs: ";
    
    	cin >> input;
    
    	prtname(input);
    
    	return 0;
    }
    
    void prtname(std::string str)
    {
    	cout << "The birds name is: " << str;
    	cout << "The lenght of the name is: " << str.length;
    }

  2. #2
    Join Date
    Apr 2013
    Posts
    42

    Re: length of a string

    got it; dumb me.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured