/*
* DisplayPath.c
*
* Created on: Feb 28, 2011
* Author: karthikeyan.D
*/
#include <stdio.h>
#include <conio.h>
#include <stdlib.h>
#include <direct.h>
void DisplayFullPath(char *relPath)
{
/*Buffer*/
char full[_MAX_PATH];
if(_fullpath(full, relPath, _MAX_PATH) != NULL)
printf("The full path is: %s\n", full);
else
printf("Invalid path\n");
}
int main()
{
// For displaying the actual path
DisplayFullPath("test.txt");
// For displaying the current working directory and file name
DisplayFullPath("\\test.txt");
// Displaying up to two sub_directories
DisplayFullPath("..\\test.txt");
// Display full path
DisplayFullPath(".");
return 0;
}
OUTPUT:
The full path is: E:\WORK\March2011\DispalyFullPath\test.txt
The full path is: E:\test.txt
The full path is: E:\WORK\March2011\test.txt
The full path is: E:\WORK\March2011\DispalyFullPath
No comments:
Post a Comment