Knowledge Walls
Venkatesan
Hyderabad, Andhra Pradesh, India
Passcode:
capacity() in String Class in CPP of Programming in CPP
1861 Views
Usage 
The capabilty function is used to return size for the string in bytes based on store space assigned.
Syntax 
str.capacity()
Example
#include <iostream>
#include <string>

int main ()
{
  std::string p ("Welcome");
  std::cout << "size of welcome: " << p.size() << "\n";
  std::cout << "length of welcome: " << p.length() << "\n";
  std::cout << "capacity of welcome: " << p.capacity() << "\n";
  return 0;
}
Output 
Size of welcome:=9
Length of welcome:=9
capacity of welcome:=13
Previous Topics
Previous lessons of current book.
String Class in CPP of Programming in CPP
String Class in CPP of Programming in CPP
String Class in CPP of Programming in CPP
String Class in CPP of Programming in CPP
Classes and Objects in CPP of Programming in CPP
Best Lessons of "Programming in CPP"
Top lessons which are viewed more times.
String Class in CPP of Programming in CPP
Math Library Functions of Programming in CPP
String Class in CPP of Programming in CPP
Classes and Objects in CPP of Programming in CPP
User-defined Functions of Programming in CPP
Math Library Functions of Programming in CPP
String Class in CPP of Programming in CPP
  Copyright © 2014 Knowledge walls, All rights reserved
KnowledgeWalls
keep your tutorials and learnings with KnowledgeWalls. Don't lose your learnings hereafter. Save and revise it whenever required.
Click here for more details