I feel stupid -- determine the full path to a file

Dave Smith dave at thesmithfam.org
Thu Dec 6 13:48:00 MST 2007


Shane Hathaway wrote:
> Dave Smith wrote:
>   
>> int main( int argc, char **argv )
>> {
>>     if( argc != 2 )
>>     {
>>         printf( "Usage: %s <path>\n", argv[0] );
>>         return 1;
>>     }
>>
>>     char output[PATH_MAX];
>>     realpath( argv[1], output );
>>     printf( "%s\n", output );
>>
>>     return 0;
>> }
>>     
>
> Didn't your mother teach you to check error codes?  Your hard drive
> might spontaneously combust during the realpath() call, yet this program
> will happily print garbage and say it was miraculously successful anyway.

Did you forget to attach your patch? I can't seem to find it in your 
last email.

--Dave



More information about the PLUG mailing list