Horje
string c++ Code Example
indexing strings in c++
// string::operator[]
#include <iostream>
#include <string>

int main ()
{
  std::string str ("Test string");
  for (int i=0; i<str.length(); ++i)
  {
    std::cout << str[i];
  }
  return 0;
}
c++ write string
#include <iostream>

int main() {
	std::cout << "Hello" << std::endl; //endl = end line/new line
    // or
    printf("hello");
    
}
string c++
#include <string>
std::begin		| returns an iterator to the beginning of a container 
std::end		| returns an iterator to the end of a container 
std::size		| returns the length of string
std::to_string	| converts a number to string
std::stoi		| converts a string to a signed integer
std::getline 	| read data from an I/O stream into a string
std::swap  		| specializes the std::swap algorithm
std::empty 		| checks whether the container is empty
how to use string in c++
// C++ Program to demonstrate the working of
// getline(), push_back() and pop_back()
#include <iostream>
#include <string> // for string class
using namespace std;
 
// Driver Code
int main()
{
    // Declaring string
    string str;
 
    // Taking string input using getline()
    getline(cin, str);
 
    // Displaying string
    cout << "The initial string is : ";
    cout << str << endl;
 
    // Inserting a character
    str.push_back('s');
 
    // Displaying string
    cout << "The string after push_back operation is : ";
    cout << str << endl;
 
    // Deleting a character
    str.pop_back();
 
    // Displaying string
    cout << "The string after pop_back operation is : ";
    cout << str << endl;
 
    return 0;
}




Cpp

Related
c++ random float Code Example c++ random float Code Example
define type c++ Code Example define type c++ Code Example
Anagram Code Example Anagram Code Example
attention nlp Code Example attention nlp Code Example
find permutations Code Example find permutations Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
8