Linux / UNIX Tech Support Forum
This is a discussion on C question within the Coding in General forums, part of the Development/Scripting category; You are required to create a program which simulate command grep in Unix. Let us call it grep2. grep2 will ...
|
|||||||
| Coding in General Discussion on PHP/Perl/Python/Ruby/GNU C or C++. MySQL, PgSQL and (X)HTML or any other programming languages you want. |
![]() |
|
|
LinkBack | Thread Tools | Display Modes |
|
|||
|
You are required to create a program which simulate command grep in
Unix. Let us call it grep2. grep2 will take a set of parameters. The first parameter is the pattern to be searched. The rest of the parameters are just file names. grep2 will search in each file for those line(s) that contain(s) the pattern. The output of grep2 is in the following format: filename: the line containing the pattern Your grep2 needs to check the number of parameters. If the number of parameters is not correct, grep2 displays its usage. For each specified file name, if grep2 cannot open it for reading, it displays the error message telling its user the failed file name. You also need to do any other possible checks. Since you do not know how many characters there are on each line, you need to dynamically allocate memory for each line read from a file. |
| Sponsored Links | ||
|
|
![]() |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) |
|
| Thread Tools | |
| Display Modes | |
|
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| phpmyadmin question | paul555 | Databases servers | 2 | 13-07-2007 08:27 AM |
| Squid Question | asterisk | Linux software | 2 | 17-05-2007 04:52 PM |
| C question | TOP | Coding in General | 3 | 10-03-2006 11:08 PM |
| question | TOPHUMAN | Shell scripting | 1 | 06-02-2006 01:25 PM |
| Redirecting question | sonaikar | Linux software | 1 | 25-06-2005 12:18 AM |