fseek in c code example
Example 1: fseek function in c
FILE* fp;
fseek(fp, 23, SEEK_END);
fseek(fp, 23, SEEK_SET);
fseek(fp, 10, SEEK_CUR);
Example 2: fputs in c
#include <stdio.h>
int main () {
FILE *fp;
int c;
fp = fopen("file.txt","r");
while(1) {
c = fgetc(fp);
if( feof(fp) ) {
break ;
}
printf("%c", c);
}
fclose(fp);
return(0);
}
Example 3: fputs in c
#include <stdio.h>
int main () {
FILE *fp;
fp = fopen("file.txt", "w+");
fputs("This is c programming.", fp);
fputs("This is a system programming language.", fp);
fclose(fp);
return(0);
}