a simple program to perform writing operation to a text file and then read and display the text from file. How do I rectify it and how to avoid using "#define _CRT_SECURE_NO_WARNINGS" I am using visual studios 2018 I have tried multiple times but the output seems to go infinitthe output
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <stdlib.h>
void main()
{
FILE *fp1, *fp2;
fp1 = fopen("text.txt", "w");
printf("enter no of lines");
int line;
scanf("%d", &line);
char txt[1000];
for (int i=0; i < line; i++)
{
gets( txt);
fprintf(fp1, "s", txt);
}
fclose(fp1);
char txt2[1000];
fp2 = fopen("text.txt", "r");
while (1)
{
fgets(txt2, 1000, fp2);
if (txt2 == EOF)
break;
printf("%s", txt2);
}
fclose(fp2);
}`