Sorry if this is out there, I cannot find what I'm looking for.
What I'm trying to do is read a list of number from a txt file and then count how many total numbers there is in the txt file.
Cannot seem to figure this out.
Thanks
This is a discussion on Counting Int's in a File within the C++ Programming forums, part of the General Programming Boards category; Sorry if this is out there, I cannot find what I'm looking for. What I'm trying to do is read ...
Sorry if this is out there, I cannot find what I'm looking for.
What I'm trying to do is read a list of number from a txt file and then count how many total numbers there is in the txt file.
Cannot seem to figure this out.
Thanks
You can just read each number one at a time in a loop, then increment a counter each time.
What have you tried that didn't work?
I guess I'm new to File I/O how does it read the numbers, does it differentiate between the spaces and the number like 123? And info on a good file I/O Tut.
There's heaps of tutorials on this site
Originally Posted by brewbuck:
Reimplementing a large system in another language to get a 25% performance boost is nonsense. It would be cheaper to just get a computer which is 25% faster.
Simply using >> in a loop should be all you need to read in a file populated with distinct numeric values (ints) seperated by whitespace.
I used to be an adventurer like you... then I took an arrow to the knee.