i'm trying to open a file and read all the charecters and remove all punctuation then write back to the file , however for words like that's i dont want to remove the ' . for example:
bin.txt
Code:
'the house ! ? house? when sat on that's ,,.
should end up as :
Code:
the house house when sat on that's
i want to insert a blank space where the punctuation was. i've attempted to do this however my code doesnt seem to be changing the file, here is my code
Code:
void append( void )
{
FILE *f;
int i;
char temp[80];
char finish[80];
if ( ( f = fopen(NAME, "r+b" ) ) == NULL) {
exit(1);
}
while ( fgets ( temp, sizeof temp, f ) != NULL ) {
if( temp[79] == '\n' ){
temp[80] == '0';
}
for( i = 0; i < 80; i++){
if ( ( temp[i] == '.' || temp[i] == '!' || temp[i] == ',' ||
temp[i] == '-' || temp[i] == '?' || temp[i] == '+' ||
temp[i] == '"' || temp[i] == ':' || temp[i] == ';' ||
temp[i] == '`' || temp[i] == '\'' && temp[i+1] == ' ' ||
temp[i] == '(' || temp[i] == ')' ) ){
temp[i] = ' ';
}
finish[i] = temp[i];
fseek( f, -1, SEEK_CUR );
fputc( finish[i], f );
fflush( f );
}
}
fclose ( f );
}
where have i gone wrong?