0
votes

First I'll start off by saying I have read the link below:

fprintf debug assertion fail

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!

1
I don't have an answer, but what sort of shenanigans is j+pTxWbHf110c->? - JoeFish
You need to escape backslashes: "C:\\ro_apps\\..." - William Pursell
The link you posted has the answer. - P.P
Thank you William. And I left out a bit of code as I'm running a for loop Joe, so that's where the j comes from. - TZPike05

1 Answers

2
votes

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;
}