词条 | fgetpos |
释义 | 函数名: fgetpos 功 能: 取得当前文件的句柄 用 法: int fgetpos(FILE *stream,*fpos_t filepos); 程序例: #include <string.h> #include <stdio.h> int main(void) { FILE *stream; char string[] = "This is a test"; fpos_t filepos; /* open a file for update */ stream = fopen("DUMMY.FIL", "w+"); /* write a string into the file */ fwrite(string, strlen(string), 1, stream); /* report the file pointer position */ fgetpos(stream, &filepos); printf("The file pointer is at byte\\ %ld\", filepos); fclose(stream); return 0; } 程序例2: void DeleteRowData(int RowNum) { /* typedef __int64 fpos_t1;*/ typedef fpos_t; FILE *fin; char strsub[20]; /**strsub 没显示*/ fpos_t pos_w; fpos_t pos_r; fpos_t pos; int i,k,L=1; char *one_line; L=RowNum; *strsub=0; one_line = (char *) malloc(1000*sizeof(char)); fin = fopen ("data.TXT","rb+"); for (i=1;i<L;i++) fgets(one_line,999,fin); fgetpos (fin,&pos_w); /*该函数在casio dt930上行不通,不解*/ fgets(one_line,999,fin); fgetpos (fin,&pos_r); pos = pos_r; while (1 == 1) { fsetpos (fin,&pos); if (fgets(one_line,999,fin) ==NULL) break; fgetpos (fin,&pos_r); pos = pos_w; fsetpos (fin,&pos); fprintf(fin,"%s",one_line); fgetpos (fin,&pos_w); pos = pos_r; } fclose(fin); //sprintf(strsub,"%s,%d","test3",L); //Display(7, 10,(UB *)" ", 0); /* 清空*/ //Display(7, 10,(UB *)strsub, 0); return; |
随便看 |
百科全书收录4421916条中文百科知识,基本涵盖了大多数领域的百科知识,是一部内容开放、自由的电子版百科全书。