I have program here from msdn.
my problem is how to get output such as "fox" or when read backward output such as "over the". what syntax or commnad i need to use.
/* STRSTR.C */
#include <string.h>
#include <stdio.h>
char str[] = "lazy";
char string[] = "The quick brown dog jumps over the lazy fox";
char fmt1[] = " 1 2 3 4 5";
char fmt2[] = "1234567890123456789012345678901234567890123456789 0";
void main( void )
{
char *pdest;
int result;
printf( "String to be searched:\n\t%s\n", string );
printf( "\t%s\n\t%s\n\n", fmt1, fmt2 );
pdest = strstr( string, str );
result = pdest - string + 1;
if( pdest != NULL )
printf( "%s found at position %d\n\n", str, result );
else
printf( "%s not found\n", str );
}
Output
String to be searched:
The quick brown dog jumps over the lazy fox
1 2 3 4 5
12345678901234567890123456789012345678901234567890
lazy found at position 36
sample output i need when found position "lazy" at 36 then
output such as:
in front of lazy word is: fox
2 step backward is: over the