Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Phillk6751

lines of code...

This topic is 6025 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

in msvc++6.0 i can figure out how many lines of code are in ONE file of my project but is there a way for it to tell you how many lines of code are in your TOTAL project? if so how?

Share this post


Link to post
Share on other sites
Advertisement
heres something I wrote a while back to do that, kinda naff but it was only a quick 5 min job, just compile it as a console program and type the path of the project folder, just make sure there arn''t any gaps as cin doesnt do them and I never got around to improving it


  
#include <fstream.h>
#include <windows.h>
#include <io.h>
#include <string.h>

void Count(char FullPath[561],int& Total,char FilePath[260]);

int main()
{
char PathName[300];
char FullPath[561];
int Counter = 0;
int Total = 0;
cin >> PathName;

SetCurrentDirectory(PathName); // Set directory to working one


struct _finddata_t c_file; // Struct to hold data

long hFile; // File handle


if( (hFile = _findfirst( "*.cpp", &c_file )) == -1L ) // Search for a file

{} // If not file found

else
{
strcpy(FullPath,PathName);
strcat(FullPath,"\\");
strcat(FullPath,c_file.name);
Count(FullPath,Total,c_file.name);

while( _findnext( hFile, &c_file ) == 0 ) // keep going til no files found

{
strcpy(FullPath,PathName);
strcat(FullPath,"\\");
strcat(FullPath,c_file.name);
Count(FullPath,Total,c_file.name);

}
_findclose( hFile ); // Close file

}

if( (hFile = _findfirst( "*.h", &c_file )) == -1L ) // Search for a file

{} // If not file found

else
{
strcpy(FullPath,PathName);
strcat(FullPath,"\\");
strcat(FullPath,c_file.name);
Count(FullPath,Total,c_file.name);

while( _findnext( hFile, &c_file ) == 0 ) // keep going til no files found

{
strcpy(FullPath,PathName);
strcat(FullPath,"\\");
strcat(FullPath,c_file.name);
Count(FullPath,Total,c_file.name);

}
_findclose( hFile ); // Close file

}

cout << Total << " Lines in total\n";

return 0;
}

void Count(char FullPath[561], int& Total,char FilePath[260])
{
int Counter = 0;
ifstream fin(FullPath);
char ch;
while(fin.get(ch))
{
if(ch == ''\n'')
Counter++;
}
Counter++;
fin.close();
cout << FilePath << " has " << Counter << " Lines\n";
Total += Counter;
}


Ballistic Programs

Share this post


Link to post
Share on other sites
wow!!!! thanks man...its a neat little program...you can also just put it in the project folder yourself and hit "." and enter and not have to worry about spaces in the folders, address etc.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!