I want to make a C program that creates files for my lab class.
But with this code I am getting a warning with the fopen_s
function.
#include <stdio.h>
int main(void)
{
int i , j , seira , sum , temp;
printf("Give the number of exercise series:\n");
scanf("%d" , &seira);
printf("Give me the number of total exercises\n");
scanf("%d" , &sum);
FILE *fp;
char name[FILENAME_MAX];
j = seira;
temp = sum;
if (j < 10)
{
for (i = 1; i <= temp; i++)
{
_snprintf(name , sizeof(name) , "Homework0%d_Group03_%d.c", j , i);
fopen_s(&fp , name , "w");
fclose(fp);
}
}
else if (j >= 10)
{
for (i = 1; i <= temp; i++)
{
_snprintf(name , sizeof(name) , "Homework%d_Group03_%d.c", j , i);
fopen_s(&fp , name , "w");
fclose(fp);
}
}
return 0;
}
This is the warning I get with gcc:
How can I get rid of this warning?