I'm doing a program that count the lines of a .cpp
file, the number of classes, the number of comments, the number of functions, and the number of lines inside a class or a function.
One of my problems it's that I can't compare the char where I am and the next of it.
Here's my code:
while(readfile.good())
{
string compare;
while(!readfile.eof())
{
std::getline(readfile, compare);
number_of_lines++;
if(readfile.peek() == 47 && /*here i need to compare next character*/)
lines_of_comment++;
if((offset = compare.find("/*clase*/", 0)) != string::npos)
{
lines_of_comment++;
number_of_class++;
}
else if ((offset = compare.find("/*funcion*/",0)) != string::npos)
{
lines_of_comment++;
number_of_functions++;
}
else if ((offset = compare.find("/*end*/",0)) != string::npos)
lines_of_comment++;
}
}
How can I compare that next character?
And if you can give me some ideas for how can I count lines inside a function.