Hello! I'm new to C programming and I have a question. I'm trying to write a C program that that can:

Open a file (the file name is unknown) located within the same directory as the executable file, search through the contents of the file for a particular keyword (for instance the word "money") and then store the numbers that follow that word in an array (there will be an unknown length of numbers following the word "money"). The numbers that follow the word "money" will be in a column.

Once I perform this I need to be able to do the same thing for all of the files within the directory. The program should be able to do this for as many files that are in the directory and the number of files and their names will vary from time to time. The only constant with the files will be that they will always be text files.

I know how to open a file that I know the name of, but not one that is unknown. Also, I know how to search through a file but not how to store the numbers that come after the keyword. If anyone can get me started on this or can point me in the right direction I would be very grateful.

Check the code snippets section. IIRC, you'll find examples that can be combined to do everything you want.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.