couting {} within code

I am looking to write a loop that will count the number of {} in a program but I am not sure as how to start this one:

My first thought is that I would need a loop that would examine every single character in the code?

Any hints or suggestion very gratefully received
You could use fstreams to read in the code file as a textfile and just check every character. You'd be risking inception errors though.
Maybe there is another way to write a program which counts the number of blocks - enclosed by { ..} in a C++ source.
You could read from a stream using getline, which takes an optional delimiter parameter.
Topic archived. No new replies allowed.