Reputation: 1188
First I'll start off by saying I have read the link below:
I'm receiving the same error he/she did, however mine is not due to the same reason. Here's the code, which is in C:
FILE * fp;
fp = fopen("C:\ro_apps\IandQ.csv", "w");
fprintf(fp, "%f\n", (j+pTxWbHf110c->cAnalogOutputBuffer)->re);
The error I get states:
Debug Assertion Failed!
Program: (irrelevant) File: f:\dd\vctgools\crt_bld\self_x86\crt\src\fprintf.c Line: 55
Expression: (str != NULL)
I saw in the other link someone had stated using debug to see if the file was even opening before using the fprintf command. Mine doesn't open. Any tips or tricks?
Thanks!
Upvotes: 0
Views: 3758
Reputation: 105886
Your filename is wrong. You have to escape every backslash \
:
fp = fopen("C:\\ro_apps\\IandQ.csv", "w");
Also you should always check if fopen
failed:
if(fp == NULL){
perror("Couldn't open file: C:\\ro_apps\\IandQ.csv\n");
return;
}
Upvotes: 2