You can do it, but using a temp file is much more preferable.
This probably makes some unwarranted assumptions.
Code:
#include <stdio.h>
#include <string.h>
int main ( ) {
long pos, oldpos = 0;
char buff[BUFSIZ];
FILE *fp = fopen("foo.txt", "r+" );
while ( fgets( buff, sizeof buff, fp ) != NULL ) {
char *p = strrchr( buff, ';' );
int offset = p - buff + 1; /* the 0 or 1 */
pos = ftell(fp); /* the start of the next line */
/* From the start of the current line, to the last ';' + 1 */
fseek( fp, oldpos + offset, SEEK_SET );
fputc( '1', fp );
fflush( fp );
fseek( fp, pos, SEEK_SET );
oldpos = pos;
}
fclose( fp );
return 0;
}
$ gcc -W -Wall -ansi -pedantic -O2 foo.c
$
$ cat foo.txt && ./a.exe && cat foo.txt
Manufacturer;Model;2007;Signal_Name;640;2;0;Tester ;0
Another_Manufacturer;Some_Model;2007;Signal2_Name; 756;4;0;Some_Tester;0
Manufacturer;Model;2007;Signal_Name;640;2;0;Tester ;1
Another_Manufacturer;Some_Model;2007;Signal2_Name; 756;4;0;Some_Tester;1