1

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.

1
  • 1
    Open the file in append mode? Commented Jun 13, 2012 at 14:33

1 Answer 1

4

You need to open the file in append mode. Change the second parameter to fopen from "w" to "a".

Sign up to request clarification or add additional context in comments.

1 Comment

Wow... haha. Very easy fix. Thank you.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.