00001 #include <iostream> 00002 #include "strutil.h" 00003 00004 int main() 00005 { 00006 char buffer[128]; 00007 char buffer2[128]; 00008 00009 strcpy( buffer, "Esto ES UNA prueba" ); 00010 00011 printf( "Cadena original: '%s'\n", buffer ); 00012 00013 strtolower( buffer ); 00014 printf( "Cadena: '%s'\n", buffer ); 00015 00016 strtoupper( buffer ); 00017 printf( "Cadena: '%s'\n", buffer ); 00018 00019 strsubstring( buffer, buffer2, 0, 4 ); 00020 printf( "Subcadena: '%s'\n", buffer2 ); 00021 00022 printf( "Posición de '%s' en '%s': %d\n", 00023 buffer2, buffer, strpos( buffer, buffer2 ) 00024 ); 00025 00026 printf( "Posición de 'ES' en '%s': %d\n", 00027 buffer, strpos( buffer, " ES " ) 00028 ); 00029 00030 printf( "Posición de '%s' en '%s': %d\n", 00031 buffer, buffer2, strpos( buffer2, buffer ) 00032 ); 00033 00034 printf( "Posición de NULL en '%s': %d\n", 00035 buffer, strpos( buffer, NULL ) 00036 ); 00037 00038 strinsert( "NO ", buffer, 5 ); 00039 printf( "Insertando NO queda: '%s'\n", buffer ); 00040 00041 strsubstring( buffer, buffer2, 100, 4 ); 00042 printf( "Subcadena: '%s'\n", buffer2 ); 00043 00044 strsubstring( buffer, buffer2, 5, 2 ); 00045 printf( "Subcadena: '%s'\n", buffer2 ); 00046 00047 strsubstring( buffer, buffer2, 5, 200 ); 00048 printf( "Subcadena: '%s'\n", buffer2 ); 00049 00050 printf( "Buffer es '%s'\n", buffer ); 00051 00052 strdel( buffer, 4, 3 ); 00053 printf( "Quitando 3 de 4, queda '%s'\n", buffer ); 00054 00055 strreplace( buffer, "S", "Z" ); 00056 printf( "Reemplazando S por Z, queda '%s'\n", buffer ); 00057 00058 strreplace( buffer, "UNA", "OTRA" ); 00059 printf( "Reemplazando UNA por OTRA, queda '%s'\n", buffer ); 00060 00061 strclear( buffer2 ); 00062 for(unsigned int i = 0; i < strlen( buffer ); ++i) { 00063 strconcatchar( buffer2, buffer[ i ] ); 00064 printf( "%s\n", buffer2 ); 00065 } 00066 00067 return 0; 00068 }