Espacios de nombres
Variantes
Acciones

std::basic_string::substr

De cppreference.com
< cpp‎ | string‎ | basic string
 
 
Strings biblioteca
Terminadas en nulo
Original:
Null-terminated strings
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Cadenas de bytes
Multibyte cuerdas
Cadenas anchas
Clases
Original:
Classes
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
 
std::basic_string
Las funciones miembro
Original:
Member functions
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Elemento acceso
Original:
Element access
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Los iteradores
Original:
Iterators
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Capacidad
Original:
Capacity
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Operaciones
Original:
Operations
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
basic_string::substr
Buscar
Original:
Search
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Constantes
Original:
Constants
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Terceros funciones
Original:
Non-member functions
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
(C++11)(C++11)(C++11)
(C++11)(C++11)
(C++11)(C++11)(C++11)
(C++11)
(C++11)
Clases de ayuda
Original:
Helper classes
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
 
basic_string substr( size_type pos = 0,
                     size_type count = npos );
Devuelve una subcadena [pos, pos+count). Si la subcadena solicitado dura más allá del final de la cadena, o si count == npos, la subcadena devuelta es [pos, size()) .
Original:
Returns a substring [pos, pos+count). If the requested substring lasts past the end of the string, or if count == npos, the returned substring is [pos, size()).
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

Contenido

[editar] Parámetros

pos -
posición del primer carácter que desea incluir
Original:
position of the first character to include
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
count -
longitud de la subcadena
Original:
length of the substring
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

[editar] Valor de retorno

String que contiene la subcadena [pos, pos+count) .
Original:
String containing the substring [pos, pos+count).
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

[editar] Excepciones

std::out_of_range if pos > size().

[editar] Complejidad

Lineal en count
Original:
Linear in count
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

[editar] Ejemplo

#include <string>
#include <iostream>
 
int main()
{
    std::string a = "0123456789abcdefghij";
 
    std::string sub1 = a.substr(10);
    std::cout << sub1 << '\n';
 
    std::string sub2 = a.substr(5, 3);
    std::cout << sub2 << '\n';
 
    std::string sub3 = a.substr(12, 100);
    std::cout << sub3 << '\n';
 }

Salida:

abcdefghij
567
cdefghij

[editar] Ver también

copias personajes
Original:
copies characters
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(función miembro público) [editar]