![]() |
| | #1 |
| Registered User Join Date: Sep 2007
Posts: 21
| Writing a Unix Search Program, some questions However, naturally, we don't have anything in our text covering this...yay. So, what code would I use to a) cycle through a list of files and b) compare a string against a file name. Obviously, not asking you to write my program for me, I just need to know what to use in these instances. If you've got any resources for writing Unix programs in C, as well, please link them, as that's what the course is on. |
| Acolyte is offline | |
| | #2 |
| Banned Join Date: Aug 2001 Location: Visalia, CA, USA
Posts: 3,699
| I have posted code that is unix compatible that does this in the past. If it still exists, feel free to just copy mine (and learn nothing). If the threads were old enough to be purged, just show us where you are thus far and we can baby step you through it. |
| master5001 is offline | |
| | #3 |
| and the hat of Jobseeking Join Date: Aug 2001 Location: The edge of the known universe
Posts: 21,693
| There's even a tree walker in the FAQ.... But if you want to try yourself without peeking at the answer, look up these functions in the manual pages - opendir - readdir - closedir |
| Salem is offline | |
| | #4 |
| Ex scientia vera Join Date: Sep 2007
Posts: 464
| Write a function that lists all files in a dir - that's easy. When one of the files listed is a directory, append it to the current working directory and pass that path to the function that lists files in a dir. You might want to consider some kind of a multi-threading mechanism to speed it up, or fork(I've never used fork, not a big linux programmer, but I imagine it could be used to accomplish the task - If I'm wrong, be kind as to correct me).
__________________ "What's up, Doc?" "'Up' is a relative concept. It has no intrinsic value." |
| IceDane is offline | |
![]() |
| Thread Tools | |
| Display Modes | |
|
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Writing a program to make a calendar | Northstar | C Programming | 17 | 11-07-2007 11:34 AM |
| Using variables in system() | Afro | C Programming | 8 | 07-03-2007 12:27 PM |
| writing a grep program | cnovice | C Programming | 8 | 11-22-2005 08:05 AM |
| writing a program called tail like the one in unix | fanaonc | C Programming | 2 | 11-04-2001 02:20 AM |
| Remotely accessing an NT PC from a Unix C++ program | bhorrobi | C++ Programming | 0 | 10-01-2001 09:42 AM |