Prepare Interview

Mock Exams

Make Homepage

Bookmark this page

Subscribe Email Address

Language%20in%20C%20Interview%20Questions%20and%20Answers

Question: How to obtain a path of the given file?

Answer: The function searchpath( ) searches for the specified file in the subdirectories of the current path. Following program shows how to make use of the searchpath( ) function.

#include "dir.h"

void main ( int argc, char *argv[] )
{
char *path ;
if ( path = searchpath ( argv[ 1 ] ) )
printf ( "Pathname : %sn", path ) ;
else
printf ( "File not foundn" ) ;
}
Is it helpful? Yes No

Most helpful rated by users:

©2024 WithoutBook