how to get all files on a directory of .c file

i need to get all files names on a c file directory to I can open every file and read from them to write on other files......

I solved the problem of reading and writing for a specific file to another file ....

but i want that for text files in .c file directory so how to read a names of files 1 by 1
I searched a lot but no codes about that

I don't know what language your using(i.e. shell script, perl, vb, etc.) but the below will give you a list of files:

cd .c
for f in `ls *.txt`
do
  file=`echo ${f}`
  .......your code to process file.......
done

oh sorry I forget about that... Iam talking about a c code

See the man pages for opendir() and readdir().

1 Like

In addition to what JohnGraham said, here are some examples:

List the files in a Unix directory with C

List files in current directory - C / C++
How can I get a list of files in a directory using C or C++? - Stack Overflow

1 Like

Thank you guys I don't know where you find those info...... but this is not google for sure :eek: