Answer the question
In order to leave comments, you need to log in
How to find the number of numbers in a txt file?
How can I count the number of numbers in a txt file in C? The numbers are real and separated by spaces, for example: 3.12 5.44 5.55 8.90
Answer the question
In order to leave comments, you need to log in
Took the file size (man readdir)
Requested memory for reading the file by file size (man calloc)
Opened the file (man open)
Read it (man read)
Closed the file (man close)
Counted the number of spaces in the buffer, checked that after the last one there is a number (eliminate the situation when there is a space after the last number), if so,
added
one
.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question