Download here. find_replace.pdf
// Filename : find_replace.c
// Author : A.G.Raja
// Website : agraja.wordpress.com
// License : GPL
#include <stdio.h>
void find_replace(char *to, unsigned char *from, char find, char replace)
{
const char *p; char *q;
for(p = from, q = to; *p != ”; p++)
{
if ( *p != find)
{ *q=*p; q++; }
else
{ *q=replace; q++; }
} *q = ”;
}
int main()
{
unsigned char *str = “this is original text” ;
unsigned char str2[strlen(str)];
printf(“before:%s\n”,str);
find_replace(str2,str,’s’,’x’);
printf(“after:%s\n”,str2);
return 0;
}
// This program can be used for single char only.
// string with more than one char is not supported
Download here. find_replace.pdf
Tips:
This function can be used to trim white spaces in file.
See this page for an example: Trim
See this page for string replace: string replace
Pingback: C program to trim blank spaces « Applied Electronics Journal
Pingback: C Find Replace Program « Applied Electronics Journal
if you can help me to ellaborite a c code changing vector
v(1,0,0,0) to v(0,1,0,0)