Reading total amount in binary files

Aug 26, 2012 at 10:57am
Hello, I would ask how to read how many total characters are in a binary file.
For example, the following strings are written in a binary file
Helloworld/0asdf/0thisisastring/0
There are no empty spaces and /0 is the terminating symbol.
So I have the task to determine the average number of characters in each string.
In this case it would be 27/3 = 9
Now my question is how to find out how many total characters are there and then divide them by the number of terminating symbols. (also how to find out the number of the terminating symbols)
Aug 26, 2012 at 12:25pm
Please help me, it can't be that hard.....
Aug 26, 2012 at 1:50pm
how to find out the number of the terminating symbols:
1
2
3
4
5
count(container, element):
   count <- 0
   traverse(container: iterator)
      if( iterator = element )
         count <- count+1
Aug 26, 2012 at 2:14pm
? what?
I am asking about C++ binary files something like
while (file.read...
what to type after this
Aug 26, 2012 at 2:50pm
Aug 26, 2012 at 4:17pm
ne555 has given you pseudo code because, you're right, it's not that hard. Here's mine: Read every character and count the NULLs, when the EOF is reached, look at the stream position.
Topic archived. No new replies allowed.