Answers for "str in cpp"

C++
2

c_str in c++

What does c_str () do in C++?
  
The basic_string::c_str() is a builtin function in C++ which returns a pointer
to an array that contains a null-terminated sequence of characters representing 
the current value of the basic_string object.
Posted by: Guest on August-06-2021
3

string in cpp

// you want to include <string>
#include <string>
#include <iostream>

int main() 
{
  string helloWorld = "Hello World!"; // creating string and assigning
  std::cout << helloWorld;            // will output what you assigned it!
                                      /* you can also use strings with user 
                                      input (cin/getline)*/
  string namePerson{};
  getline(cin, namePerson); // getline allows for multi word input
  std::cout << namePerson;  // outputs name which person inputted
}
Posted by: Guest on October-20-2020

Browse Popular Code Answers by Language