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
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.
"Owners of dogs will have noticed that, if you provide them with food and water and shelter and affection, they will think you are god. Whereas owners of cats are compelled to realize that, if you provide them with food and water and shelter and affection, they draw the conclusion that they are gods."
-Christopher Hitchens