LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 06-08-2005, 11:08 AM   #1
rajsun
Member
 
Registered: Mar 2005
Posts: 61

Rep: Reputation: 15
Getting file names in a directory using C on linux.


Hi All,

I need a small program using C to get all file names in a specified directory in linux by giving file type as input (like *.c or *.so).


Thanks in advance,
Suresh B
 
Old 06-08-2005, 11:26 AM   #2
rstewart
Member
 
Registered: Feb 2005
Location: Sunnyvale, CA
Distribution: Ubuntu
Posts: 205

Rep: Reputation: 38
Why are you trying to reinvent find or ls?
 
Old 06-08-2005, 11:27 AM   #3
Matir
LQ Guru
 
Registered: Nov 2004
Location: San Jose, CA
Distribution: Debian, Arch
Posts: 8,507

Rep: Reputation: 128Reputation: 128
rajsun: Use the opendir() function to read the files in a directory.
 
Old 06-09-2005, 05:03 PM   #4
jim mcnamara
Member
 
Registered: May 2002
Posts: 964

Rep: Reputation: 36
opendir()
sacndir()
closedir()

.. see dirent.h
 
Old 06-10-2005, 12:47 AM   #5
enemorales
Member
 
Registered: Jul 2004
Location: Santiago, Chile
Distribution: Ubuntu
Posts: 410

Rep: Reputation: 31
You can also look here:

http://www.linuxquestions.org/questi...hreadid=331944

It's another thread in the same forum, but related to processes...
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
awk: fatal:cannot open file for reading (no such file or Directory) in Linux sangati vishwanath Linux - Software 4 07-06-2005 12:59 AM
SSL Install not going well. Linux server, Apache directions? File names not matching. maineweb Linux - Newbie 1 11-18-2004 09:18 AM
monitoring directory to get the modified file names appas Programming 1 09-06-2004 04:56 AM
view long file names from windows in linux wildcat22 Linux - General 4 09-03-2004 04:14 PM
Windows file names in Linux console mbegovic Linux - General 4 04-30-2004 01:09 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 11:00 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration