/* Category: C -  Extract the directory information from a file name */
/*                      /etc/local/bin/fdmount --> fdmount  */
/*                      This mimics the unix command 'basename'.  */
/* Uploaded on 02-08-07 */
/* To execute change the extension to .C from .txt */
/* Downloaded from http://tech.groups.yahoo.com/group/programs4all/ */
Knowledge No: 0225
Topic: Extract the directory information from a file name
Program:
========
 
#include <string.h>
 
char *basename(const char *FullName);
 
main()
{
  char *FullName = "/usr/local/bin/fdmount";
 
  printf("Full name is %s \n", FullName);
 
  printf("File name is %s \n", basename(FullName));  
}
 
/***********************************************************/
 
char *basename(const char *FullName)
{
  static char *File;
 
  /* ...        I guess DOS users will have to change the direction of
     ...        the slash. */
 
  File = strrchr(FullName, '/');
 
  /* ...        If no slashes have been found, Return the full file name */
 
  if (File == NULL)
  {
    File = FullName;
  }
  else
  {
    File++;
  }
  return(File);
}
 
/* Downloaded from http://tech.groups.yahoo.com/group/programs4all/ */
Date: 02-08-07.
Regards,
Rengaraj.R

For More Information Join: http://tech.groups.yahoo.com/group/programs4all/
Daily one program will be uploaded


 

Click to join programs4all 


      
____________________________________________________________________________________
Be a better friend, newshound, and 
know-it-all with Yahoo! Mobile.  Try it now.  
http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ

[Non-text portions of this message have been removed]

Reply via email to