Coding Challenge #17

Coding Challenge Series / Technical Interview Series

You are writing code for an embedded system. There are some restrictions on memory and I/O that you must follow.

Your challenge is to create a file search function. The function is provided an ASCII string and the name of the file. The file API follows this pattern:

array = ReadFile(filename, startindex)

Notice how there isn’t a length? :)  The ReadFile function returns 64 bytes at a time (as possible). You may not keep more than 64 bytes of the file in memory at any time. (No double buffering, etc.). The data in the file is represented as ASCII characters. Additionally, a block of memory may only be read once.

To get the file length, a function is provided:

length (integer) = FileLength(filename)

The search string may be longer than 64 characters.

One Comment

Comments are closed.