Click here to Skip to main content
15,892,737 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
how to take input values from .csv file and execute in .txt file.
ex:
Student-1, 500
Student-2, 200
Student-3, 800

fprintf("The Student-1 marks are = %f", Student-1);

In this condition i will take only before "," my variable and after "," variable value.

Please let me explain this problem.

What I have tried:

Student-1, 500
Student-2, 200
Student-3, 800

fprintf("The Student-1 marks are = %f", Student-1);

In this condition i will take only before "," my variable and after "," variable value.
Posted
Updated 18-Nov-18 5:59am
Comments
OriginalGriff 18-Nov-18 11:07am    
This is not a good question - we cannot work out from that little what you are trying to do.
Remember that we can't see your screen, access your HDD, or read your mind - we only get exactly what you type to work with.
Use the "Improve question" widget to edit your question and provide better information.

1 solution

Read each line of the csv file. Split it into tokens using strtok, _strtok_l, wcstok, _wcstok_l, _mbstok, _mbstok_l[^]. Convert the second string to an integer using atoi, _atoi_l, _wtoi, _wtoi_l[^] (not float since the numbers in your data are integers). Print the results. Or you could print the number as a string if you are not using it in any calculations.
 
Share this answer
 

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