You are on page 1of 4

#include <string.

h>
#include <stdio.h>
#include <conio.h>
#include <iostream.h>
//declaracion de funciones
menu_principal();
len();
cpy();
cmp();
cat();
chr();
lwr();
upr();
rev();
set();

void main()
{
int opc;
do
{
do
{
clrscr();
menu_principal();
cin>>opc;
} while ((opc<1)&&(opc>10));
switch (opc)
{
case 1: len();
break;
case 2: cpy();
break;
case 3: cmp();
break;
case 4: cat();
break;
case 5: chr();
break;
case 6: lwr();
break;
case 7: upr();
break;
case 8: rev();
break;
case 9: set();
break;
}
}while (opc==10);
getch();
return ;
}

menu_principal()
{ //variables
clrscr();
textcolor(15);
gotoxy(25,5); cprintf("<<<<<<< Menu Principal >>>>>>>");
textcolor(9);
gotoxy(20,7); cprintf("1) STRLEN (LONGITUD DE CADENA)");
gotoxy(20,8); cprintf("2) STRCPY (COPIA UNA CADENA A OTRAS)");
gotoxy(20,9); cprintf("3) STRCMP (COMPARA CADENAS)");
gotoxy(20,10); cprintf("4) STRCAT (CONCATENA CADENAS)");
gotoxy(20,11); cprintf("5) STRCHR (BUSCA UNA LETRA EN UNA CADENA)");
gotoxy(20,12); cprintf("6) STRLWR (CONVIERTE MAYUSCULAS A
MINUSCULAS)");
gotoxy(20,13); cprintf("7) STRUPR (CONVIERTE MINUSCULAS A
MAYUSCULAS)");
gotoxy(20,14); cprintf("8) STRREV (INVIERTE UNA CADENA)");
gotoxy(20,15); cprintf("9) STRSET (ESTABLECE CARACTER EN CADENA)");
gotoxy(20,16); cprintf("10) SALIR");
gotoxy(20,18); cprintf("Escoger una opci�n (1-10): ");
return 0;
}
len()
{
char *texto;
int longitud = 0;
clrscr();
cout <<"Ingrese un texto: ";
gets(texto);
longitud = strlen(texto);
cout << "Se ha ingresado " << longitud << " caracteres";
getch();
return 0;
}
cpy()
{
char *texto_origen;
char *texto_destino;
clrscr();
cout <<"Ingrese un texto: ";
gets(texto_origen);
strcpy(texto_destino, texto_origen);
cout << "El mensaje es: " << texto_destino;
getch();
return 0;
}
cmp()
{
char *texto_1;
char *texto_2;
int resultado;
clrscr();
cout <<"Ingrese primer texto: ";
scanf(texto_1);
gets(texto_1);
cout <<"Ingrese segundo texto: ";
gets(texto_2);
resultado = strcmp (texto_1,texto_2);
cout << resultado;
getch();
return 0;
}
cat()
{
char *texto_1;
char *texto_2;
clrscr();
cout <<"Ingrese primer texto: ";
gets(texto_1);
cout <<"Ingrese segundo texto: ";
gets(texto_2);
strcat(texto_1, texto_2);
cout << "Su frase es: " << texto_1 << endl;
getch();
return 0;
}
chr()
{
char *string;
char *ptr;
char c;
clrscr();
cout <<"Ingrese el texto: ";
gets(string);
cout<<"Ingrese el caracter: ";
cin>>c;
ptr = strchr(string, c);
if(ptr)
printf("El caracter %c esta en la posicion: %d \n", c, ptr-string);
else
printf("El caracter no funciona \n");
getch();
return 0;
}
lwr()
{
char *str;
char *ptr;
clrscr();
cout <<"Ingrese el texto: ";
gets(str);
printf("\n Su texto en mayuscula es: %s ", str);
ptr=strlwr(str);
printf("\n\n Su texto convertido a minuscula es: %s ", ptr);
getch();
return 0;
}
upr()
{
char *string;
char *ptr;
clrscr();
cout <<"Ingrese el texto: ";
gets(string);
printf("\n\t Su texto en minuscula es: %s ", string);
ptr = strupr(string);
printf("\n\t Su texto convertido a mayuscula es: %s", ptr);
getch();
return 0;
}
rev()
{
char *forward;
clrscr();
cout <<"Ingrese el texto: ";
gets(forward);
printf("\n La cadena antes de la funcion: %s ", forward);
strrev(forward);
printf("\n La cadena despues de la funcion: %s ", forward);

getch();
return 0;
}
set()
{
char *string;
char symbol = '*';
clrscr();
cout <<"Ingrese la clave: ";
gets(string);
printf("\n\t Su clave: %s", string);
strset(string, symbol);
printf("\n\t Su clave cifrada es: %s", string);
getch();
return 0;
}

You might also like