| string::push_back |
public member function |
void push_back ( char c ); |
|
Append character to string
Appends a single character to the string content, increasing its size by one.
To append more than one character at a time, refer to either member append or operator+= .
Parameters
- c
- Character to be appended
Return Value
none
Example
// string::push_back
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
int main ()
{
string str;
ifstream file ("test.txt",ios::in);
while (!file.eof())
{
str.push_back(file.get());
}
cout << str;
return 0;
}
|
This example reads an entire file character by character, appending each character to a string object using push_back.
Basic template member declarations
( basic_string<charT,traits,Allocator> )
void push_back ( charT c );
|
See also
| string::end | Return iterator to end (public member function) |