Like programming ,Like dataminning
#define NO_ENDEAVOR_BELIEF '#'
#define PERSISTENCE '|'
#define LUCK '!'
int MyLifeOfFunc()
{
FILE *My_File; struct stat *Mylife ;
sprintf( My_FIle_Name,"%s/%s",getenv( "LIFE" ),"My_Life.conf" ) ;
if ( ( My_File=fopen(My_FIle_Name, "r" ) ) == NULL ) {
fprintf( stderr, "%s\n", "My_Life.conf not exist,too bad" ) ;
return ( -1 ) ;
}
YourLoseNum = 0 ;
YourSuccessNum = 0 ;
while ( fgets ( Str_Action , 256, My_File ) ) {
Mylife = (struct stat *)malloc( sizeof(struct stat));
stat ( My_File, Mylife ) ;
if ( !S_ISDIR(Mylife->st_mode))
continue ;
sprintf( TouchCmd, "touch %s/*", Str_Action ) ;
system( TouchCmd ) ;
if((Str_Action [0]== NO_ENDEAVOR_BELIEF)||((strlen(Str_Action)-1)<1)) {
YourLoseNum ++ ;
continue ;
}
Str_Action[ strlen ( Str_Action ) -1 ] = '\0';
if((Str_Action [0]==LUCK)&&
( Str_Action [ (strlen(Str_Action)-2)]== PERSISTENCE)) {
YourSuccessNum ++;
}
free( Mylife ) ;
}
fclose( My_File ) ;
(YouWillLoseNum) < (YouWillSuccessNum ) ? printf( "Success\n" ) : printf( "Fail\n" );
return ( 0 ) ;
}
|