Original Post
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?
#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;
}
This topic has been locked by a moderator. New replies are not allowed.
With your permission, GameDev.net uses analytics cookies to understand how people use the platform. You can accept analytics or continue with necessary cookies only. Learn more