#include<stdio.h>
#include <string.h>
#include <windows.h>
#define PATH "F:\\c\\projects\\Banking Management System\\data\\"
#define F_PWD "pwd.txt"
#define FILENAME(q1, path, f_) q1 path f_ q1
void main() {
printf("\n%s", FILENAME("\"",PATH, F_PWD));
FILE *fp=fopen(FILENAME("\"",PATH, F_PWD), "w");
if (fp==NULL){
perror("\nERROR: ");
exit(EXIT_FAILURE);
}
fprintf(fp,"%d,%s,%f\n",1,"Anil Dhar",1000.00);
fclose(fp);
}
Problem
The printf shows the correct file name with path: "F:\c\projects\Banking Management System\data\pwd.txt"
However,perror shows: ERROR: Invalid argument
It doesn't create/write into the file, even if, I remove the following condition:
if (fp==NULL){ perror("\nERROR: "); exit(EXIT_FAILURE); }
Why is perror showing "Invalid argument" ?