Writing to a CSV file in C

c, csv

Solution

You could achieve this through `fprintf`

for(i = 0; i < num_of_students; i++)
     fprintf(fptr, "%s,%d,%d,%d,%d,%d\n", name, mark1, mark2, mark3, mark4, mark5);

Problem

My C program generates this data. I need to place it into a CSV file, so that it can be used by another program. How can I achieve this? ``` Student1 Mark1 Mark2 Mark3 Mark4 Mark5 Student2 Mark1 Mark2 Mark3 Mark4 Mark5 Student3 Mark1 Mark2 Mark3 Mark4 Mark5 Student4 Mark1 Mark2 Mark3 Mark4 Mark5 Student5 Mark1 Mark2 Mark3 Mark4 Mark5 ```

Original source