Have to write a program that mimikes a grep. It has to search thru a given file for a certain pattern. I have no idea where to start. Help please.

Recommended Answers

All 2 Replies

grep stands for global / regular expression / print. First try a search on a way of performing regular expressions in C. Then find a good tutorial on how those work.

> I have no idea where to start.
Read a file, and print it out unmodified.

Then add code to find a fixed string.

Then add code to implement each feature of a regexp in turn.

Each is a small-ish step, built on the success of the previous step.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.