A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://www.tutorialspoint.com/cpp_standard_library/cpp_string_push_back.htm below:

C++ String Push Back

C++ String Library - push_back Description

It appends character c to the end of the string, increasing its length by one.

Declaration

Following is the declaration for std::string::push_back.

void push_back (char c);
C++11
void push_back (char c);
C++14
void push_back (char c);
Parameters

c − It is a character object.

Return Value

none

Exceptions

if an exception is thrown, there are no changes in the string.

Example

In below example for std::string::push_back.

#include <iostream>
#include <fstream>
#include <string>

int main () {
   std::string str;
   std::ifstream file ("sample.txt",std::ios::in);
   if (file) {
      while (!file.eof()) str.push_back(file.get());
   }
   std::cout << str << '\n';
   return 0;
}

string.htm


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4