I apologize for this seemingly relatively simple task that I can’t figure out. I wasn’t able to seem to find a way to write data to a new row in a .csv file using the C language. I’m saving 3 variables to the .csv file, and currently they will always replace A1:C1. Here is my print commands:
fs = fopen("C:\\Documents and Settings\\ajkaas\\Desktop\\110c.csv", "w");
if(fs == NULL){
printf("Couldn't open file\n");
return;
}
fprintf(fs, "%u,%11.8f,%11.8f\n", message63->rcvrBitErrorCount,
(double)message63->rcvrTotalBitErrorCount / (double)(message63->rcvrBlockIndex * message63->rcvrBitsPerBlock),
(double)message63->rcvrBlockErrorCount / (double)(message63->rcvrBlockIndex));
fclose(fs);
I know that looks messy, and I apologize for that as well. I was looking at some documentation but couldn’t seem to find an answer. Every time the for loop runs that this code is in, my A1:C1 rows are replaced but I want it to drop down a row every time the loop runs again. Does that make any sense? Let me know if you need anything additional and thank you.
You need to open the file in append mode. Change the second parameter to fopen from “w” to “a”.