I am quite new to C programming and I was wondering how I can save 2 .csv files into an integer array and then print it. The first .csv file is a 2d array and the 2nd is a 1d array.
Asked
Active
Viewed 283 times
-1
-
3Hello, please provide a [mcve] of what you tried. – Amessihel Oct 28 '20 at 00:46
-
Have you gone through this question (https://stackoverflow.com/questions/12911299/read-csv-file-in-c), yet? – Luka Kralj Oct 28 '20 at 00:49
-
Does this answer your question? [Read .CSV file in C](https://stackoverflow.com/questions/12911299/read-csv-file-in-c) – Luka Kralj Oct 28 '20 at 00:51
-
2Read a character. If it is a comma: the current field has ended. If it is a LF: the current record has ended. Otherwise/default: the character should be added to the current field. Rinse,repeat. Good luck. – wildplasser Oct 28 '20 at 00:56
-
If your input is numeric, the `strtoX` (e.g. `strtol()`, `strtoul()`, `strtod()`, etc..) are custom made for parsing values from lines of input. Along with `strtok()` (or `strsep()` if empty-fields are possible) or `fgets()` followed by `sscanf()` if the number of fields are fixed, or `strspn()` and `strcspn()` combinations... – David C. Rankin Oct 28 '20 at 04:10
1 Answers
0
you did not post any code so i do not have any example where are you facing problem.
but in .csv file fields are separated with commas so you can use strtok
to separate the values and store them in the desired array.
you should also take care of the size of the array too. you can make it dynamic using realloc
.
you can use read .csv this as an example.

Saransh Dixit
- 43
- 7