I have the following code in which I want to modify printf and write in a file. I have used macros for the same.
#include<stdio.h>
#define printf(A) {FILE *fp;\
fp=fopen("oup.txt","wb");\
fprintf(fp,A);\
fclose(fp);}
int main()
{
int i;
for(i=0;i<10;i++)
printf("Hello\n");
}
Above code gives error:
`this declaration has no storage class or type specifier`at fp=fopen(..) and printf in the code
Please suggest any solution.Also suggest any other way for doing the same.