In my C program I am calling the shell command "find . -name \"*.bin\""
using the following code:
FILE *fptr = popen("find . -name \"*.bin\"", "r");
Now I want to open each file this command finds in order to read the data from this file. I have tried with the following way but it isn;t working:
int numbers[5];
int i = 0;
char files[1000];
FILE *ptr;
FILE *fptr = popen("find . -name \"*.bin\"", "r");
while ( fgets(files, 1000, fptr) != NULL)
{
ptr = fopen(files, "r");
fscanf(ptr, "%d", &numbers[i]);
i++;
}
How can I manage this? I would really appreciate any help!