Search and read the file name in C++ or C

  c++, file, fileinfo

I have a scenario where I want to search my directory for all the files which have ".ip" in their filename and then read the filenames(I don’t need to open the file). I also need the time-stamp for each files and store them. I am using a Linux system and would like the solution to be in C++ or C.

Here’s what my directory looks like:

 MyFolder/Data
   ── server.linux.config
   ── linux.115.65.45.123:9000.ip
   ── windows.54.34.105.192:3050.ip
   ── local.127.0.0.1:8080.ip
   ── server.bin
   ── keys.bin
  

For example, I need to need to read the filename "linux.115.65.45.123:9000.ip" since it has "ip" in its file name and get ip_address "115.65.45.123", port no. "9000", system "linux" after reading the name and then the time-stamp of the file.

Source: Windows Questions C++

LEAVE A COMMENT