Code:
/* edited for the purpose of this post */
#include <stdio.h>
#include <io.h>
#include <time.h>
int main( void )
{
struct _finddata_t c_file;
long hFile;
/* Find first file in current directory */
if( (hFile = _findfirst( "*.*", &c_file )) == -1L )
printf( "No *.* files in current directory!\n" );
else
{
printf( "Listing of files\n\n" );
printf( "\nRDO HID SYS ARC FILE DATE %25c SIZE\n", ' ' );
printf( "--- --- --- --- ---- ---- %25c ----\n", ' ' );
printf( ( c_file.attrib & _A_RDONLY ) ? " Y " : " N " );
printf( ( c_file.attrib & _A_SYSTEM ) ? " Y " : " N " );
printf( ( c_file.attrib & _A_HIDDEN ) ? " Y " : " N " );
printf( ( c_file.attrib & _A_ARCH ) ? " Y " : " N " );
printf( " %-12s %.24s %9ld\n",
c_file.name, ctime( &( c_file.time_write ) ), c_file.size );
/* Find the rest of the files */
while( _findnext( hFile, &c_file ) == 0 )
{
printf( ( c_file.attrib & _A_RDONLY ) ? " Y " : " N " );
printf( ( c_file.attrib & _A_SYSTEM ) ? " Y " : " N " );
printf( ( c_file.attrib & _A_HIDDEN ) ? " Y " : " N " );
printf( ( c_file.attrib & _A_ARCH ) ? " Y " : " N " );
printf( " %-12s %.24s %9ld\n",
c_file.name, ctime( &( c_file.time_write ) ), c_file.size );
}
_findclose( hFile );
}
return 0;
}
first off, im lazy so im not gonig to turn this into C++, ill leave it in C, so you can learn something.
Second if you are new to C++, you really should AVOID this. This uses topics you are most likely unfamiliar with, and will have enormous problems trying to implement this, but have fun anyway.
-LC