Professional Documents
Culture Documents
PROGRAMACIN
II Ciclo
GUA
LABORATORIO N2
2013- II
MANEJO DE STRINGS EN C++
Objetivos:
Introduccin terica:
std::string s;
std::string t = s;
Define t como una variable de tipo std::string que inicialmente contiene una
copia de los caracteres en s, donde s puede ser un string o un string literal.
os << s
is >> s
s+t
Procedimiento:
Ingrese al programa Dev C++, haga clic sobre el men File->New-> Source File
y digite el cdigo del programa Hello World ! :
#include <iostream>
#include <string>
int main()
{
{ const std::string s = "a string";
std::cout << s << std::endl; }
{ const std::string s = "another string";
std::cout << s << std::endl; }
return 0;
}
#include <iostream>
#include <string>
int main()
{
{ const std::string s = "a string";
std::cout << s << std::endl;
{ const std::string s = "another string";
std::cout << s << std::endl; }}
return 0;
}
_______________________________________________________
_______________________________________________________
_______________________________________________________
_______________________________________________________
4.5 Es vlido este programa? por qu? Reescrbalo para hacerlo vlido.
#include <iostream>
#include <string>
int main()
{
{ std::string s = "a string";
{ std::string x = s + ", really";
std::cout << s << std::endl; }
std::cout << x << std::endl;
}
return 0;
}
#include <iostream>
#include <string>
int main()
{
std::cout << "What is your name? ";
std::string name;
std::cin >> name;
std::cout << "Hello, " << name
<< std::endl << "And what is yours? ";
std::cin >> name;
std::cout << "Hello, " << name
<< "; nice to meet you too!" << std::endl;
return 0;
FUNDAMENTOS DE PROGRAMACIN
Rbrica Laboratorio 2
Desarrollar programas que manipulan strings, utilizando la librera estndar para ingreso de
Resultado:
resultados.
Criterio de
Cdigo fuente.
desempeo :
Apellidos de los
Periodo: 2013-1
alumnos:
Seccin: Fecha: Docente: Juan Carlos Bueno
Documentos de Evaluacin
Hoja de Trabajo: Cdigo fuente: X Proyecto: Otros:
Comentario al alumno: