So now that I figured out how to write to an excel file (Thank you guys so much for that!), I’m wondering if there is a way to write to a second column in excel. I’m actually sending two different variables to this excel file and I’d like them side-by-side as opposed to right next to each other. I didn’t see any other questions asking this for the C language, so thought I’d throw it out that. If there is one, feel free to link me the question and I apologize for wasting the space!
File * fp;
fp = fopen("C:\\Documents and Settings\\MyName\\Desktop\\Filename.csv", "w");
if(fp == NULL){
printf("Couldn't open file\n");
return;
}
for (j = 0; j<Variable0; j++){
fprintf(fp, "%f\n", (j+Variable1);
fprintf(fp, "%f\n", (j+Variable2);
}
You are not writing an Excel file, you are writing a comma-separated value file (CSV). It can however, still be opened with Excel. There is a huge difference. Each column is separated with a comma. Each row is seperated by a newline character.
Make sure you remember to close the file as well!