I know I put a post up before on this but here is all the rest so I have an assignment were we have to have the program look at some lines of code and pick out certain things. Now from some help I have the beginning where the program can view the file but unsure who I can get it to pull out the rest
This is what I have so far
1 2 3 4 5 6 7 8 9
|
main(){
std::ifstream ifs ("Example.code");
while (ifs){
std::string line;
std::getline(ifs, line);
}
return 0
}
|
Now I wasn't sure if I should put this code in the main or put it in a different function but right now I'm thinking that keeping it in the main might work the best.
Now the rest I'm thinking that if I put the functions into a class since they are similar that should work.
Let me know what you think. These are the info that I need to pull from a text file
Number of total lines in the file – you need this for percentages.
Percentage of blank lines
Percentage of statements, as figured by counting semicolons (;)
Percentage of blocks, as figured by counting braces ({ and })
Percentage of pointer references, as figured by counting “->”
Percentage of comment lines, including both // and /* / style comments. Bear in mind that either type of comment can appear in either type of file, and that you should count each line that occurs between a /* and a */ as a comment line.