// quick+dirty offset seeker (c) 1994 by Rolf K. Wilms #include +lt;iostream.h+gt; #includ

---
Master Index Current Directory Index Go to SkepticTank Go to Human Rights activist Keith Henson Go to Scientology cult

Skeptic Tank!

// quick&dirty offset seeker (c) 1994 by Rolf K. Wilms #include #include #include #include #include #include #include #include #include int main(int argc, char *argv[]) { if(argc != 3) { cout << "Usage: offset searchstring infile" << endl; exit(1); } ifstream in(open(argv[2], O_RDONLY|O_BINARY)); in.seekg(0); char *line, *p = NULL, buffer[4096]; unsigned int pos = 0, len; do { line = NULL; in.gets(&line, 0); len = strlen(line); if(line != NULL) { p = strstr(line, argv[1]); if(line != buffer) free(line); if(p != NULL) break; } pos += len+1; } while(in.good); in.close(); if(p != NULL) { cout << (pos + p - line); } else { cout << "no match"; exit(1); } exit(0); }

---

E-Mail Fredric L. Rice / The Skeptic Tank