Click here to Skip to main content
14,922,057 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
If I have a csv file that contains
a,z
b,y
c,x
d,w
.,.
.,.
.,.
y,b
z,a

How to read these data and store the alphabet before the comma in an array, and the alphabet after the comma in another array. such as [a,b,c,d,e,....][z,y,x,w,....]

Thank you.

What I have tried:

I used fopen("filename", "r"), and fgetc() to get the data, but it didn't work.
Posted
Updated 7-Feb-21 19:00pm

1 solution

You can use fgets to read an entire line of text at a time and then strtok to separate the characters.
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900