33 lines
695 B
C++
33 lines
695 B
C++
#pragma hdrstop
|
|
#include <condefs.h>
|
|
#include <string.h>
|
|
#include <stdio.h>
|
|
|
|
//---------------------------------------------------------------------------
|
|
#pragma argsused
|
|
int main(int argc, char **argv)
|
|
{
|
|
char string[500], *ptr;
|
|
int lengSRC;
|
|
|
|
if ( argc < 3 )
|
|
{
|
|
puts( "Search'n'Replace v1.0 | José David Guillén\n" );
|
|
puts( "snr [search] [replace]\n" );
|
|
} else {
|
|
lengSRC = strlen( argv[1] );
|
|
while ( gets( string ) != NULL )
|
|
{
|
|
if ( ( ptr = strstr( string, argv[1] ) ) == NULL )
|
|
{
|
|
puts( string );
|
|
} else {
|
|
ptr[0] = '\0';
|
|
printf("%s%s%s\n", string, argv[2], ptr + lengSRC );
|
|
}
|
|
}
|
|
}
|
|
|
|
return 0;
|
|
}
|