Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- int main()
- {
- FILE *fp;
- int num,i,out_n,length=0;
- char str[50],out[50];
- for(i=0;i<3;i++)
- {
- fp = fopen("wrtie_file_test.txt","a");
- printf("Enter string: ");
- gets(str);
- printf("Enter a number: ");
- scanf("%d",&num);
- fprintf(fp,"%s : %d\n",str,num);
- fflush(stdin);
- }
- fclose(fp);
- fp = fopen("wrtie_file_test.txt","r");
- for(i=0;i<3;i++)
- {
- fscanf(fp,"%s : %d\n",out,&out_n);
- length = length+ftell(fp);
- fseek(fp,length,SEEK_SET);
- fflush(stdin);
- printf("%s : %d\n",out,out_n);
- printf("Pointer location: %d\n",length);
- }
- fclose(fp);
- return 0;
- }
Add Comment
Please, Sign In to add comment