I'm trying to make a function scan a file for a string and replace part of the string.I've got it to scan the file and detect the string but replaceing the part of the string is a problem.I'm trying to make it turn 0200 0424 into 0100 0424.Here the code I've done:
Code:
int replace_str(FILE *x)
{
int *cp[8];
int i=0;
int c;
fseek(x,0,SEEK_SET);
while( (c = fgetc( x )) != EOF )
{
if ( c == 0x01 ) { cp[i]=&c;
if ( c == 0x00 ) { cp[i]=&c;
if ( c == 0x04 ) { cp[i]=&c;
if ( c == 0x24 ) { cp[i]=&c;
if ( c == 0x02 ) { cp[i]=&c;
if ( c == 0x00 ) { cp[i]=&c;
if ( c == 0x04 ) { cp[i]=&c;
if ( c == 0x24 ) { cp[5]=0x01 ; i++;}
}}}}}}}
}
return 0;
}