How to read all .txt files in a directory in C -


i have short program read , sort text tile in c.

if want read many files, there substitute for:

file *f f = fopen("*.txt", "rw");

thanks in advance.

f = fopen("*.txt", "rw"); won't work in case.

the usual way depends on operating system. on unix-like systems, simple way invoke program command line "my_pgm *.txt" , let shell find matching files. (you'll multiple arguments, each 1 being file name.) understand microsoft oses require program find files itself.

to more or less portably, i'd use opendir() , readdir() examine directory entries , see whether matched desired pattern.


Comments

Popular posts from this blog

shopping cart - Page redirect not working PHP -

php - How to modify a menu to show sub-menus -

python - Installing PyDev in eclipse is failed -