Click to See Complete Forum and Search --> : Searching text in file


August 20th, 1999, 10:17 AM
Sir,
I am using Visual C++ 6.0. I need to determine number of occurances of a text say "showpage" in a file. I am using fget(c) to determine this. The problem is if the file size becomes large it takes large time to scan the file. Is there any other way that is more eficient. Is there any function available for this.
sajjad

August 20th, 1999, 10:23 AM
fgetc is pretty slow since it reads one character at a time. You should try buffering it, read it into a large buffer, say 4096 in size. THen search that entire buffer for it, then read another buffer etc until the file is ended.