<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Program in C in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/program-in-c/m-p/3577705#M702971</link>
    <description>Yes, as Biswajit said "stat()" is the answer.  Here is a small program for the same. &lt;BR /&gt;================&lt;BR /&gt;#include&lt;STDIO.H&gt;&lt;BR /&gt;#include&lt;SYS&gt;&lt;BR /&gt;&lt;BR /&gt;int main() {&lt;BR /&gt;&lt;BR /&gt;        struct stat bstat;&lt;BR /&gt;&lt;BR /&gt;        if (stat("filename", &amp;amp;bstat) &amp;lt; 0) {&lt;BR /&gt;                fprintf(stderr, "file does not exist\n");&lt;BR /&gt;        } else {&lt;BR /&gt;                fprintf(stderr, "file does exist\n");&lt;BR /&gt;        }&lt;BR /&gt;}&lt;BR /&gt;===========&lt;BR /&gt;&lt;BR /&gt;-Amit&lt;/SYS&gt;&lt;/STDIO.H&gt;</description>
    <pubDate>Thu, 07 Jul 2005 07:12:01 GMT</pubDate>
    <dc:creator>Amit Agarwal_1</dc:creator>
    <dc:date>2005-07-07T07:12:01Z</dc:date>
    <item>
      <title>Program in C</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/program-in-c/m-p/3577703#M702969</link>
      <description>Hi Guys,&lt;BR /&gt;&lt;BR /&gt;  Is there anyway I can write a program in C to check whether a file exist in a path?&lt;BR /&gt;regards&lt;BR /&gt;Henry</description>
      <pubDate>Thu, 07 Jul 2005 04:30:36 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/program-in-c/m-p/3577703#M702969</guid>
      <dc:creator>Henry Chua</dc:creator>
      <dc:date>2005-07-07T04:30:36Z</dc:date>
    </item>
    <item>
      <title>Re: Program in C</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/program-in-c/m-p/3577704#M702970</link>
      <description># man 2 stat&lt;BR /&gt;&lt;BR /&gt;- Biswajit&lt;BR /&gt;</description>
      <pubDate>Thu, 07 Jul 2005 04:41:15 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/program-in-c/m-p/3577704#M702970</guid>
      <dc:creator>Biswajit Tripathy</dc:creator>
      <dc:date>2005-07-07T04:41:15Z</dc:date>
    </item>
    <item>
      <title>Re: Program in C</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/program-in-c/m-p/3577705#M702971</link>
      <description>Yes, as Biswajit said "stat()" is the answer.  Here is a small program for the same. &lt;BR /&gt;================&lt;BR /&gt;#include&lt;STDIO.H&gt;&lt;BR /&gt;#include&lt;SYS&gt;&lt;BR /&gt;&lt;BR /&gt;int main() {&lt;BR /&gt;&lt;BR /&gt;        struct stat bstat;&lt;BR /&gt;&lt;BR /&gt;        if (stat("filename", &amp;amp;bstat) &amp;lt; 0) {&lt;BR /&gt;                fprintf(stderr, "file does not exist\n");&lt;BR /&gt;        } else {&lt;BR /&gt;                fprintf(stderr, "file does exist\n");&lt;BR /&gt;        }&lt;BR /&gt;}&lt;BR /&gt;===========&lt;BR /&gt;&lt;BR /&gt;-Amit&lt;/SYS&gt;&lt;/STDIO.H&gt;</description>
      <pubDate>Thu, 07 Jul 2005 07:12:01 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/program-in-c/m-p/3577705#M702971</guid>
      <dc:creator>Amit Agarwal_1</dc:creator>
      <dc:date>2005-07-07T07:12:01Z</dc:date>
    </item>
    <item>
      <title>Re: Program in C</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/program-in-c/m-p/3577706#M702972</link>
      <description>If you want to check file availablity with c coding then, you can simply use fopen() also as,&lt;BR /&gt;&lt;BR /&gt;#include &lt;STDIO.H&gt;&lt;BR /&gt;&lt;BR /&gt;main()&lt;BR /&gt;{&lt;BR /&gt;&lt;BR /&gt;  FILE *fp;&lt;BR /&gt;  fp=fopen("filename1","r");&lt;BR /&gt;  if (!fp){&lt;BR /&gt;    printf ("Filename filename1 is not existing\n");&lt;BR /&gt;  } else {&lt;BR /&gt;    printf ("Filename filename1 is existing\n");&lt;BR /&gt;  }&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;Change filename1 with full path as like "/tmp/test/filenam1" also in fopen().&lt;BR /&gt;&lt;BR /&gt;hth.&lt;/STDIO.H&gt;</description>
      <pubDate>Thu, 07 Jul 2005 07:26:21 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/program-in-c/m-p/3577706#M702972</guid>
      <dc:creator>Muthukumar_5</dc:creator>
      <dc:date>2005-07-07T07:26:21Z</dc:date>
    </item>
    <item>
      <title>Re: Program in C</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/program-in-c/m-p/3577707#M702973</link>
      <description>if you want to write this to incorporate it into a script, you should not waste your time doing so. unix has the 'test' command (man test) which has lots of options for checking files.</description>
      <pubDate>Fri, 08 Jul 2005 01:49:09 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/program-in-c/m-p/3577707#M702973</guid>
      <dc:creator>dirk dierickx</dc:creator>
      <dc:date>2005-07-08T01:49:09Z</dc:date>
    </item>
    <item>
      <title>Re: Program in C</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/program-in-c/m-p/3577708#M702974</link>
      <description>Hi Henry,&lt;BR /&gt;I used same routine of Muthukumar with fopen function. It works with any c and any platform.&lt;BR /&gt; &lt;BR /&gt;Antonio Vigliotti.&lt;BR /&gt;</description>
      <pubDate>Sat, 09 Jul 2005 02:05:37 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/program-in-c/m-p/3577708#M702974</guid>
      <dc:creator>Antoniov.</dc:creator>
      <dc:date>2005-07-09T02:05:37Z</dc:date>
    </item>
    <item>
      <title>Re: Program in C</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/program-in-c/m-p/3577709#M702975</link>
      <description>The stat() system call is a much better choice than fopen. First, it's cheaper in terms of system resources but more importantly, fopen() (or open()) could very easily fail even if the file actually exists. How? You specify a mode (e.g. "r") when using fopen(), if the file exists but has only write or execute bits set, your fopen() will fail. Use stat(); if it returns a zero result then the operation was okay; you then use the mode field to determine if the file is a regular file and has the desired permission bits sets. If stat returns a non-zero result then you look at errno and determine why it failed.&lt;BR /&gt;</description>
      <pubDate>Sat, 09 Jul 2005 17:50:06 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/program-in-c/m-p/3577709#M702975</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2005-07-09T17:50:06Z</dc:date>
    </item>
    <item>
      <title>Re: Program in C</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/program-in-c/m-p/3577710#M702976</link>
      <description>I agree w/ Clay.. use the stat(2) system call.. you can also use the fopen(3), if you like.&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Sat, 09 Jul 2005 19:59:20 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/program-in-c/m-p/3577710#M702976</guid>
      <dc:creator>D Block 2</dc:creator>
      <dc:date>2005-07-09T19:59:20Z</dc:date>
    </item>
    <item>
      <title>Re: Program in C</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/program-in-c/m-p/3577711#M702977</link>
      <description>Clay,&lt;BR /&gt;thank you for stat information. I read the help on stat function. I think I'll use that next time.&lt;BR /&gt; &lt;BR /&gt;Antonio Vigliotti&lt;BR /&gt;</description>
      <pubDate>Sun, 10 Jul 2005 01:27:24 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/program-in-c/m-p/3577711#M702977</guid>
      <dc:creator>Antoniov.</dc:creator>
      <dc:date>2005-07-10T01:27:24Z</dc:date>
    </item>
    <item>
      <title>Re: Program in C</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/program-in-c/m-p/3577712#M702978</link>
      <description>Don't forget the access(2) system call&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 12 Jul 2005 08:18:49 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/program-in-c/m-p/3577712#M702978</guid>
      <dc:creator>Stephen Keane</dc:creator>
      <dc:date>2005-07-12T08:18:49Z</dc:date>
    </item>
  </channel>
</rss>

