How can I read a float numbers which are in a text file using C [closed]











up vote
-3
down vote

favorite












The text file contains the text below, how to write a program to save it to a variable called 'a'?



Bank    Rate(1) Rate(2) Rate(3)
A 1.11 1.52 1.26
B 3.22 4.24 5.25
C 1.68 7.68 7.2
D 3.26 4.23 1.7









share|improve this question









New contributor




JJ Tan is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











closed as too broad by paddy, Jonathan Leffler, Welcome to Stack Overflow, David C. Rankin, qrdl Nov 5 at 7:09


Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.











  • 1




    Well, you'd probably start by opening the file, using fscanf to read the number or numbers you want into the desired variables. Come back with some code; we'd be happy to help you further.
    – Dan Farrell
    Nov 5 at 3:16










  • Or even better, open the file and read each line into a buffer and than use strtof to step through the buffer picking out value (or sscanf updating the pointer position following each conversion)
    – David C. Rankin
    Nov 5 at 4:41










  • Welcome to Stack Overflow. Please read the About page soon and also visit the links describing How to Ask a Question and How to create a Minimal, Complete, and Verifiable example. Providing the necessary details, including your code, compiler warnings and associated errors, if any, will allow everyone here to help you with your question.
    – David C. Rankin
    Nov 5 at 4:44















up vote
-3
down vote

favorite












The text file contains the text below, how to write a program to save it to a variable called 'a'?



Bank    Rate(1) Rate(2) Rate(3)
A 1.11 1.52 1.26
B 3.22 4.24 5.25
C 1.68 7.68 7.2
D 3.26 4.23 1.7









share|improve this question









New contributor




JJ Tan is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











closed as too broad by paddy, Jonathan Leffler, Welcome to Stack Overflow, David C. Rankin, qrdl Nov 5 at 7:09


Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.











  • 1




    Well, you'd probably start by opening the file, using fscanf to read the number or numbers you want into the desired variables. Come back with some code; we'd be happy to help you further.
    – Dan Farrell
    Nov 5 at 3:16










  • Or even better, open the file and read each line into a buffer and than use strtof to step through the buffer picking out value (or sscanf updating the pointer position following each conversion)
    – David C. Rankin
    Nov 5 at 4:41










  • Welcome to Stack Overflow. Please read the About page soon and also visit the links describing How to Ask a Question and How to create a Minimal, Complete, and Verifiable example. Providing the necessary details, including your code, compiler warnings and associated errors, if any, will allow everyone here to help you with your question.
    – David C. Rankin
    Nov 5 at 4:44













up vote
-3
down vote

favorite









up vote
-3
down vote

favorite











The text file contains the text below, how to write a program to save it to a variable called 'a'?



Bank    Rate(1) Rate(2) Rate(3)
A 1.11 1.52 1.26
B 3.22 4.24 5.25
C 1.68 7.68 7.2
D 3.26 4.23 1.7









share|improve this question









New contributor




JJ Tan is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











The text file contains the text below, how to write a program to save it to a variable called 'a'?



Bank    Rate(1) Rate(2) Rate(3)
A 1.11 1.52 1.26
B 3.22 4.24 5.25
C 1.68 7.68 7.2
D 3.26 4.23 1.7






c






share|improve this question









New contributor




JJ Tan is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











share|improve this question









New contributor




JJ Tan is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|improve this question




share|improve this question








edited Nov 5 at 4:37









Faraz

602413




602413






New contributor




JJ Tan is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









asked Nov 5 at 3:13









JJ Tan

1




1




New contributor




JJ Tan is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





JJ Tan is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






JJ Tan is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.




closed as too broad by paddy, Jonathan Leffler, Welcome to Stack Overflow, David C. Rankin, qrdl Nov 5 at 7:09


Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.






closed as too broad by paddy, Jonathan Leffler, Welcome to Stack Overflow, David C. Rankin, qrdl Nov 5 at 7:09


Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.










  • 1




    Well, you'd probably start by opening the file, using fscanf to read the number or numbers you want into the desired variables. Come back with some code; we'd be happy to help you further.
    – Dan Farrell
    Nov 5 at 3:16










  • Or even better, open the file and read each line into a buffer and than use strtof to step through the buffer picking out value (or sscanf updating the pointer position following each conversion)
    – David C. Rankin
    Nov 5 at 4:41










  • Welcome to Stack Overflow. Please read the About page soon and also visit the links describing How to Ask a Question and How to create a Minimal, Complete, and Verifiable example. Providing the necessary details, including your code, compiler warnings and associated errors, if any, will allow everyone here to help you with your question.
    – David C. Rankin
    Nov 5 at 4:44














  • 1




    Well, you'd probably start by opening the file, using fscanf to read the number or numbers you want into the desired variables. Come back with some code; we'd be happy to help you further.
    – Dan Farrell
    Nov 5 at 3:16










  • Or even better, open the file and read each line into a buffer and than use strtof to step through the buffer picking out value (or sscanf updating the pointer position following each conversion)
    – David C. Rankin
    Nov 5 at 4:41










  • Welcome to Stack Overflow. Please read the About page soon and also visit the links describing How to Ask a Question and How to create a Minimal, Complete, and Verifiable example. Providing the necessary details, including your code, compiler warnings and associated errors, if any, will allow everyone here to help you with your question.
    – David C. Rankin
    Nov 5 at 4:44








1




1




Well, you'd probably start by opening the file, using fscanf to read the number or numbers you want into the desired variables. Come back with some code; we'd be happy to help you further.
– Dan Farrell
Nov 5 at 3:16




Well, you'd probably start by opening the file, using fscanf to read the number or numbers you want into the desired variables. Come back with some code; we'd be happy to help you further.
– Dan Farrell
Nov 5 at 3:16












Or even better, open the file and read each line into a buffer and than use strtof to step through the buffer picking out value (or sscanf updating the pointer position following each conversion)
– David C. Rankin
Nov 5 at 4:41




Or even better, open the file and read each line into a buffer and than use strtof to step through the buffer picking out value (or sscanf updating the pointer position following each conversion)
– David C. Rankin
Nov 5 at 4:41












Welcome to Stack Overflow. Please read the About page soon and also visit the links describing How to Ask a Question and How to create a Minimal, Complete, and Verifiable example. Providing the necessary details, including your code, compiler warnings and associated errors, if any, will allow everyone here to help you with your question.
– David C. Rankin
Nov 5 at 4:44




Welcome to Stack Overflow. Please read the About page soon and also visit the links describing How to Ask a Question and How to create a Minimal, Complete, and Verifiable example. Providing the necessary details, including your code, compiler warnings and associated errors, if any, will allow everyone here to help you with your question.
– David C. Rankin
Nov 5 at 4:44












1 Answer
1






active

oldest

votes

















up vote
0
down vote













Open the file, read each line, and then scan for the floats. You can accomplish this quite easily. There are about a dozen similar questions dedicated directly to reading float numbers from files using C posted here.



Here are some similar questions on StackOverflow which you can use to help accomplish your task:



Read int OR float from file in C



How to read floats from file in c?



C - Read in float value using getchar and print out float using printf



Reading float using scanf in c






share|improve this answer




























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    0
    down vote













    Open the file, read each line, and then scan for the floats. You can accomplish this quite easily. There are about a dozen similar questions dedicated directly to reading float numbers from files using C posted here.



    Here are some similar questions on StackOverflow which you can use to help accomplish your task:



    Read int OR float from file in C



    How to read floats from file in c?



    C - Read in float value using getchar and print out float using printf



    Reading float using scanf in c






    share|improve this answer

























      up vote
      0
      down vote













      Open the file, read each line, and then scan for the floats. You can accomplish this quite easily. There are about a dozen similar questions dedicated directly to reading float numbers from files using C posted here.



      Here are some similar questions on StackOverflow which you can use to help accomplish your task:



      Read int OR float from file in C



      How to read floats from file in c?



      C - Read in float value using getchar and print out float using printf



      Reading float using scanf in c






      share|improve this answer























        up vote
        0
        down vote










        up vote
        0
        down vote









        Open the file, read each line, and then scan for the floats. You can accomplish this quite easily. There are about a dozen similar questions dedicated directly to reading float numbers from files using C posted here.



        Here are some similar questions on StackOverflow which you can use to help accomplish your task:



        Read int OR float from file in C



        How to read floats from file in c?



        C - Read in float value using getchar and print out float using printf



        Reading float using scanf in c






        share|improve this answer












        Open the file, read each line, and then scan for the floats. You can accomplish this quite easily. There are about a dozen similar questions dedicated directly to reading float numbers from files using C posted here.



        Here are some similar questions on StackOverflow which you can use to help accomplish your task:



        Read int OR float from file in C



        How to read floats from file in c?



        C - Read in float value using getchar and print out float using printf



        Reading float using scanf in c







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 5 at 3:57









        Faraz

        602413




        602413















            這個網誌中的熱門文章

            Tangent Lines Diagram Along Smooth Curve

            Yusuf al-Mu'taman ibn Hud

            Zucchini