fseek « Development « C File Q&A

Home
C File Q&A
1.array
2.binary
3.delete
4.Development
5.directory
6.fgets
7.fopen
8.fprintf
9.fscanf
10.fwrite
11.header
12.include
13.input
14.LINE
15.linux
16.open
17.output
18.pointer
19.read
20.size
21.string
22.struct
23.Text
24.windows
25.write
C File Q&A » Development » fseek 

1. fseek / rewind in a loop    stackoverflow.com

I have a situation in a code where there is a huge function that parses records line-by-line, validates and writes to another file. In case there are errors in the file, it ...

2. Using fseek to backtrack    stackoverflow.com

Is using fseek to backtrack character fscanf operations reliable? Like for example if I have just fscanf-ed 10 characters but I would like to backtrack the 10 chars can I just fseek(infile, ...

3. How is fseek() implemented in the filesystem?    stackoverflow.com

This is not a pure programming question, however it impacts the performance of programs using fseek(), hence it is important to know how it works. A little disclaimer so that it ...

4. Fseek on C problem    stackoverflow.com

I'm testing this code, but doesn't work, it always says that an error occurred :S

int main(int argc, char **argv) {
    FILE *file_pointer;
    file_pointer = fopen("text.txt","r");
 ...

5. fgetpos/fsetpos and ftell/fseek    stackoverflow.com

What's the difference between fgetpos/fsetpos and ftell/fseek? What are fgetpos and fsetpos good for?

6. C Program: How to properly use lseek() or fseek() to modify a certain part of a file?    stackoverflow.com

I have a binary file in CSV format that contains multiple records. Each record is entered in as user_name, last_name, first_name, num_wins, num_losses, num_ties. I am creating a method to ...

7. editing file using fseek    stackoverflow.com

can you help me figure out what's the problem in my code.. i wanted to edit a specific line.... thnx

#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int main (){
    char arr[50];
    char ...

8. FUSE fseek unexpected behaviour with direct_io    stackoverflow.com

I'm trying to write a FUSE filesystem that presents streamable music as mp3 files. I don't want to start to stream the audio when just the ID3v1.1 tag is read, so ...

9. fseek for fd (int fd instead of FILE*)    stackoverflow.com

Is there an equivalent of fseek for fd? I've been using int fds for a very long time, and want to use fseek... but I know there is no seek function. Thanks ...

10. Seeking by bytes in FFmpeg    stackoverflow.com

I will appreciate your advice on the following. I'am developing a video converter which based on FFmpeg's libavformat, and I need to implement an accurate seeking API. First of all, I ...

11. Inserting data at a particular position in file using fseek() in C    stackoverflow.com

Basically I want to write data to a file at a particular position and don't want to load data in to the memory for sorting it. For example if I have ...

12. fseek() doesn't work    stackoverflow.com

I have opened a file using a and r+ but when I use fseek and ftell the file pointer is always 0. My file looks like this:

 1 -3    ...

13. problem positioning FILE * with fseek    stackoverflow.com

I'm trying to solve a K&R exercise(7.7).It asks writing a program which takes filenames as arguments and searches them for a particular pattern.For the pattern matching I use the sliding window ...

14. fseek() causing an overlap in the data    stackoverflow.com

Im reading a specified chunk of a file with fseek and fread functions and then writing it to another file. For some reason in the destination file I get about 20 ...

15. fread/fseek for a single data element vs performance?    stackoverflow.com

Is a memory page loaded to main memory for each fread/fseek on a file? I am trying to implement a byte wise hashing along with BTREE in between , (i.e) If the ...

16. Alter a file (without fseek or + modes) or concatenate two files with minimal copying    stackoverflow.com

I am writing an audio file to an SD/MMC storage card in real time, in WAVE format, working on an ARM board. Said card is (and must remain) in ...

17. fseek on a file opened with _popen    bytes.com

P: n/a thomas.mertes@gmx.at Hello Recently I discovered some problem. I have some C code which determines how many bytes are available in a file. Later I use this information to malloc a buffer of the correct size before I read the bytes. Determining the number of bytes available in a file is done in 5 steps: 1. Use tell(aFile) to get ...

18. fseek-fread error    bytes.com

in parallel programing a processor executes a part of the job, but in multi-thread programming whole job is done by one processor. This statement is absolutely false. A parallel program is a program where sections are run in parallel in real time. This requires multiple processors. Each processor runs a section. Each section is called a thread. A multi-threaded program is ...

19. fseek issue    bytes.com

20. how does fseek work with the set of arguments specified as below?    bytes.com

From position 1 in the file (the SECOND byte), add the value in column-3. Now the question is: Does your column-3 contain the NUMBER of columns or the number of bytes in the number of columns? fseek ASSUMES the second argument is the OFFSET from the third argument. thanks a lot much for clearing my doubt. but the question you ve ...

21. fseek()    bytes.com

ericunfuk I have posted a few other posts before this one today, I still can't solve my problem, I think I need to elaborate my problem now. I'm trying to send a file using UDP, below is a segment of my sender app, the sender and the receiver are both on the same machine and I have an Internet emulation gateway ...

22. What's wrong with my fseek() ?    cboard.cprogramming.com

#include #include #include #include typedef struct { int integer; char string[12]; } RECORD; #define NRECORDS (50) int main () { RECORD record; int i; FILE *fp; fp = fopen("records.dat", "w+"); for (i=0; i

23. fseek problem    cboard.cprogramming.com

#include #include int main(int argc, char **argv) { FILE *file_handle; long int file_length; file_handle = fopen("file.bin","rb"); if(fseek(file_handle, 0, SEEK_END)) { puts("Error while seeking to end of file"); return 1; } file_length = ftell(file_handle); if (file_length < 0) { puts("Error while reading file position"); return 2; } printf("File length: %d bytes\n", file_length); fclose(file_handle); getch(); return(0); }

24. Understanding fseek    cboard.cprogramming.com

Code: The fseek value: -6. Token to be processed: 1123.123TESTa. Next Token: TESTa The fseek value: -6. Token to be processed: 2123.123TESTb. Next Token: 3TESTb -Next_Line- The fseek value: -6. Token to be processed: 3123.123TESTc. Next Token: TESTc The fseek value: -6. Token to be processed: 4123.123TESTd. Next Token: 3TESTd -Next_Line- The fseek value: -6. Token to be processed: 5123.123TESTe. Next ...

25. Tailing a file, fseek help    cboard.cprogramming.com

Having some troubles. The idea is that if the file size is greater than 100 bytes, then the file is sought to the 100th to last byte. Then the file is printed to the screen. I'm getting a segfault at the fseek for >100 files, and a segfault at the getc. GDB isn't really helping explain why (for my knowledge base). ...

26. fseek on different editors    cboard.cprogramming.com

27. fseek explain    cboard.cprogramming.com

Originally Posted by man fseek FSEEK(3) Linux Programmer's Manual FSEEK(3) NAME fgetpos, fseek, fsetpos, ftell, rewind - reposition a stream SYNOPSIS #include int fseek(FILE *stream, long offset, int whence); long ftell(FILE *stream); void rewind(FILE *stream); int fgetpos(FILE *stream, fpos_t *pos); int fsetpos(FILE *stream, fpos_t *pos); DESCRIPTION The fseek() function sets the file position indicator for the stream pointed to by ...

28. Problem with fseek    cboard.cprogramming.com

29. fseek failing - Error: Invalid argument    cboard.cprogramming.com

Hi all, I have a file consisting of a huge array of floats written in binary mode (fwrite). Its actually a contiguous 2D array. I need to access various parts of the array and for this I use fseek to jump a different point and the fread to read in the data. I noticed that some of my output coming out ...

30. question about fseek    cboard.cprogramming.com

Vanity of vanities, saith the Preacher, vanity of vanities; all is vanity. What profit hath a man of all his labour which he taketh under the sun? All the rivers run into the sea; yet the sea is not full; unto the place from whence the rivers come, thither they return again. For in much wisdom is much grief: and he ...

31. fseek question    cboard.cprogramming.com

[code] #include #include #include #include Ok.. so that is just a fixed up version of your code as-is. There are some issues with it that are important to realize. You are not keeping track of wrong answers at all. You should probably just exit the program if you cannot open the question file. And you never did ...

32. fseek() Question    cboard.cprogramming.com

t Open in text (translated) mode. In this mode, CTRL+Z is interpreted as an end-of-file character on input. In files opened for reading/writing with "a+", fopen checks for a CTRL+Z at the end of the file and removes it, if possible. This is done because using fseek and ftell to move within a file that ends with a CTRL+Z, may cause ...

33. fseek() changing an unrelated variable?    cboard.cprogramming.com

I'm utterly surprised that IT "WORKS" at all. By all means, this code should crash. The variable string is a pointer to char that hasn't been given a value, so when you do scanf() you are reading into a undefined memory location - you are just "lucky" enough that it doesn't crash immediately [actualy, if I make a mistake where I ...

34. fseek and stdin    cboard.cprogramming.com

35. New to 'C' using fseek(), please help    cboard.cprogramming.com

I am writing a program that saves all of its input to a binary file. I have three entries: your code(1-5), date, and sale amount. I have the program storing everything in the file, but I need to access information by the code that it was entered under. The first function retrieves the corresponding name for the code entered and them ...

36. Advantages of fseek() and fread() ?    cboard.cprogramming.com

37. fseek - need some info please    cboard.cprogramming.com

define EMAILADDRLEN 90 // this is set above in the program int e_loc = 98; // this is set above in the program if ( (out = fopen("gorseve_10774.csv","w")) != NULL ) { while ( (returnCode = fgets(lineOfText, LINESIZE, in )) != NULL) { e_loc = parseGorseveRecord(lineOfText); printf("location found %d\n", e_loc); if ( (ret = fseek(out, e_loc, SEEK_CUR)) == 0 ) { ...

38. Reg. fseek    cboard.cprogramming.com

If the size of the records is not known in advance, the only way to do it is by starting at the beginning and reading one line at a time until you reach the line you're interested in. If you use newline termination on each record and your records are text, not binary, fgets() should work nicely for this. If this ...

39. fseek and storing ints    cboard.cprogramming.com

40. fseek high cpu usage?    cboard.cprogramming.com

hi there: just a quick question. i have been working on this code which reads a file that contains information about each frame for animation (blm files). my code is controled my a GUI(slider) and then uses fseek() to locate the frame to be read. a bit like a scraching. my questions is that, does fseek() eats a lot of cpu ...

41. fseek() with stdout    cboard.cprogramming.com

You don't "read in a character where the cursor is". You simply read a character. The cursor position has nothing to do with reading a character. It is an output item. If you want to "read the character that's currently under the cursor", then you'll need to keep track of the screen's contents in a buffer some place, and seek around ...

42. Help With fseek();    cboard.cprogramming.com

Hello, I'm having problems learning about rand access files... Most of my code works, all until you get to the fseek. The output is all garbaled, I'm not sure why. I'll post the entire code, so that if it's something other than the fseek that is affecting it, you could point that out... Thanks Code: #include #include #include ...

43. fseek    cboard.cprogramming.com

44. popen and fseek    cboard.cprogramming.com

Hello Everyone, I am writing a program that does a whois and nslookup on domains listed in a text file. I am having a problem with popen and fseek. Here is the code: Code: #include #include int main() { FILE *fptr1, *fptr2, *domreadout, *nsreadout; char filename1[] = "virt.txt"; char filename2[] = "output.txt"; char buff[BUFSIZ]; char whoiscommand[150]; char nscommand[150]; char ...

45. fseek ???    cboard.cprogramming.com

46. Fseek() and overwriting data    forums.devshed.com

I am trying to use fseek to overwrite data in a file , the code works but its printing the new information to be written at the end of the line in which the data is found. Code: void updaterecord(void) { system("color 2"); struct custinfo info; FILE *customer1; customer1=fopen("customer1.txt","r"); if (customer1==NULL) printf("\n\n\t\t\t FILE WAS NOT FOUND "); else { char choice4; ...

47. Fseek SEEK_CUR backwards    forums.devshed.com

48. Fseek Backwards    forums.devshed.com

#include char initXMLDoc(int systemNumber, char *fileName); int main() { FILE *fp; printf("\nInit XML doc"); initXMLDoc(1234, "files/test.xml"); if((fp = fopen("files/test.xml", "a+b"))==NULL){ printf("\nFailed to open file"); return -1; } fseek(fp, 9, SEEK_END); fwrite("HELLO", 1, 12,fp); fclose(fp); return (0); } char initXMLDoc(int systemNumber, char *fileName){ FILE *fp; if((fp=fopen(fileName, "w"))==NULL){ printf("Failed to create initial XML document"); return 0; } // write encoding msg //fprintf(fp, ...

49. fseek()    forums.devshed.com

50. Explanation regarding fseek    forums.devshed.com

51. Listing a file with fread and fseek    forums.devshed.com

x=0; fseek(fp2, sizeof(rec)*index[x].pos, SEEK_SET); fread(&rec, sizeof(rec), 1, fp2); printf("%i ", rec.id); printf("%s ", rec.subject); printf("%i ", rec.year); printf("%i ", rec.month); printf("%i ", rec.day); printf("%s ", rec.state); printf("%s ", rec.county); printf("%f ", rec.length); printf("%s ", rec.code); while(!feof(fp2)) { x++; fseek(fp2, sizeof(rec)*index[x].pos, SEEK_SET); fread(&rec, sizeof(rec), 1, fp2); printf("%i ", rec.id); printf("%s ", rec.subject); printf("%i ", rec.year); printf("%i ", rec.month); printf("%i ", rec.day); printf("%s ...

52. fseek, ftell, lseek, ????    daniweb.com

>> Why are you using low-level file i/o?? Just use FILE* and all will be ok. The only reason to use open() is when the compiler for the target operating system doesn't have FILE* and associated functions. I inherited a lot of code from the last guy and need to change it. He used file descriptors, so I'm stuck with them ...

53. fseek()    daniweb.com

void updaterecord(void) { system("color 2"); struct custinfo info; FILE *customer1; customer1=fopen("customer1.txt","r"); if (customer1==NULL) printf("\n\n\t\t\t FILE WAS NOT FOUND "); else { char choice4; char Target[50]; int Found=0; if((customer1=fopen("customer1.txt","r"))==NULL) printf("THE FILE IS EMPTY"); else { printf("\n\n\t\t ENTER ID NUM:"); scanf("%s",&Target); while(!feof(customer1)&& Found==0) { fscanf(customer1,"%s %s %s %s %s %s %s %s",info.regis,info.Name,info.address,info.number,info.dob,info.treatment,info.allergies,info.app); if(strcmp(Target,info.regis)==0) Found=1; } if(Found) { printf("\n\t\t REGISTRATION:%s\n",info.regis); printf("\n\t\t NAME:%s\n",info.Name); printf("\n\t\t ADDRESS:%s\n",info.address); ...

54. fread() and fseek()    daniweb.com

55. Problems with fseek    daniweb.com

#include #include int main(void){ FILE * input; char * nlptr; long position; long count; char ch; int name[81]; fprintf(stdout, "please enter a text file\n"); fgets(name, 81, stdin); nlptr = strchr(name, '\n'); if(nlptr) *nlptr ='\0'; input = fopen(name, "r"); printf("enter a file position\n"); fscanf(stdin, "%d", &position); while(getchar() != '\n') continue; for(count = position; getc(input) != '\n'; count++){ fseek(input, count, SEEK_SET); ...

56. simple fseek question    tek-tips.com

I'm relatively new to fseek, so I really don't know if I'm using this call right. I want to move a file in chunks of 256 bytes at a time, but for some reason, I either get only 256 bytes to the file I'm writing to or an appending of all files into one. What am I doing wrong?FILE ...

java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.