Help answer threads with 0 replies.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


Closed Thread
  Search this Thread
Old 07-04-2007, 10:42 PM   #1
LQ Newbie
Registered: Jul 2007
Posts: 2

Rep: Reputation: 0
Need help in displaying the relative path

Hi. I was wondering if somebody can help me on this. I am writing a c program that finds a file and display its relative path if the file is found... I am not sure how I going to display the relative path.. Any suggestions? Thx

main (int argc, char * argv[])

int fileDesc; /* File Descriptor */
struct stat buf; /* Stat Struct */

if ((fileDesc = open(argv[1], O_RDONLY)) < 0)
printf ("%s: %s -- File does not exist.\n",argv[0], argv[1]);

fstat (fileDesc, & buf);

printf ("filename : %s \n", argv[1]);
printf ("relative path : \n");
printf ("Protection Mode : %o ", buf.st_mode);
printf ("Tot size : %ld\n", buf.st_size);

close (fileDesc);
return (0);

Old 07-05-2007, 03:57 PM   #2
Registered: Jun 2006
Location: Mariposa
Distribution: Slackware 9.1
Posts: 938

Rep: Reputation: 30
This is a duplicate of:
Old 07-05-2007, 04:14 PM   #3
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 911Reputation: 911Reputation: 911Reputation: 911Reputation: 911Reputation: 911Reputation: 911Reputation: 911
Please post your thread in only one forum. Posting a single thread in the most relevant forum will make it easier for members to help you and will keep the discussion in one place. This thread is being closed because it is a duplicate.

In this case I've closed the original because the dupe was in the more suitable
forum and already had a relevant answer. Please re-visit the rules you agreed to.


Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Question in displaying the relative path oliviapesayco Programming 1 06-30-2007 03:27 PM
[bash] relative path grezly Programming 1 01-16-2007 02:30 PM
relative to absolute path vishalbutte Programming 4 01-14-2006 03:17 PM
Relative Path? mikeshn Linux - General 3 05-10-2002 04:09 PM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 05:03 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration