For the following code:
#include <stdio.h>
int main(int argc, char *argv[1])
{
char *x = argv[1];
char a[5];
char b[5];
FILE *fn = fopen(x, "r");
FILE *fp;
for(int i = 0; i < 5; i++)
{
sprintf(a, "%d.txt", i);
fp = fopen(a, "w");
fread(&b, 1, 1, fn);
fwrite(&b, 1, 1, fp);
fclose(fp);
}
return 0;
}
Does the fopen() function create 5 files namely, 0.txt, 1.txt, 2.txt, 3.txt, 4.txt? Why does it do so exactly? Also, how can I read a file into an array if I don't know the amount of data the file holds?