STRING IN C++

Maha
String in c++

STRING IN C++

                A string in C++ is a sequence of characters stored in a string object data structure. The string data can be manipulated using a variety of methods and operations provided by the string object. It can be stored in memory as a character array that ends with the null character "0." The std::string class from the C++ standard library is the most common way to define a string in C++. It offers concatenation, substring, search, and other string manipulation options.

Syntax:

#include <string>  // include the string library

using namespace std;

int main() {
  string myString = "enter your string"; // initialize a string
  return 0;
}

Example:

#include <iostream>
#include <string> // include the string library
using namespace std;
int main() 
{
  string myString = "welcome Gocourse"; // initialize a string
  cout << myString << endl;
  return 0;
}

Output:

welcome Gocourse


Tags
Our website uses cookies to enhance your experience. Learn More
Accept !

GocourseAI

close
send