<?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 gethostid in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/gethostid/m-p/3031239#M718897</link>
    <description>Hi,&lt;BR /&gt;&lt;BR /&gt;I am working on getting C-knowledge, but it's not completely working yet for me :)&lt;BR /&gt;Can anyone help me out in receiving a machines hostid ??&lt;BR /&gt;&lt;BR /&gt;#include &lt;UNISTD.H&gt;&lt;BR /&gt;&lt;BR /&gt;int long g;&lt;BR /&gt;g = gethostid(void);&lt;BR /&gt;&lt;BR /&gt;int main(void)&lt;BR /&gt;{&lt;BR /&gt; printf ("The hostid of this machine is : %c\n, g");&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;I am missing something elemantary here. Any help will be much apreciated !!&lt;BR /&gt;&lt;BR /&gt;Regs David&lt;/UNISTD.H&gt;</description>
    <pubDate>Wed, 23 Jul 2003 13:37:06 GMT</pubDate>
    <dc:creator>David_246</dc:creator>
    <dc:date>2003-07-23T13:37:06Z</dc:date>
    <item>
      <title>gethostid</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/gethostid/m-p/3031239#M718897</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;I am working on getting C-knowledge, but it's not completely working yet for me :)&lt;BR /&gt;Can anyone help me out in receiving a machines hostid ??&lt;BR /&gt;&lt;BR /&gt;#include &lt;UNISTD.H&gt;&lt;BR /&gt;&lt;BR /&gt;int long g;&lt;BR /&gt;g = gethostid(void);&lt;BR /&gt;&lt;BR /&gt;int main(void)&lt;BR /&gt;{&lt;BR /&gt; printf ("The hostid of this machine is : %c\n, g");&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;I am missing something elemantary here. Any help will be much apreciated !!&lt;BR /&gt;&lt;BR /&gt;Regs David&lt;/UNISTD.H&gt;</description>
      <pubDate>Wed, 23 Jul 2003 13:37:06 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/gethostid/m-p/3031239#M718897</guid>
      <dc:creator>David_246</dc:creator>
      <dc:date>2003-07-23T13:37:06Z</dc:date>
    </item>
    <item>
      <title>Re: gethostid</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/gethostid/m-p/3031240#M718898</link>
      <description>Hi,&lt;BR /&gt;neither i know C, but&lt;BR /&gt;&lt;BR /&gt;gethostid returns a lon, whereas the printf is expecting a pointer to a null terminated strings.&lt;BR /&gt;&lt;BR /&gt;It may be this ?&lt;BR /&gt;&lt;BR /&gt;    Massimo&lt;BR /&gt;</description>
      <pubDate>Wed, 23 Jul 2003 13:46:06 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/gethostid/m-p/3031240#M718898</guid>
      <dc:creator>Massimo Bianchi</dc:creator>
      <dc:date>2003-07-23T13:46:06Z</dc:date>
    </item>
    <item>
      <title>Re: gethostid</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/gethostid/m-p/3031241#M718899</link>
      <description>Hi Massimo,&lt;BR /&gt;&lt;BR /&gt;You are probably right ( I think I understand you :)&lt;BR /&gt;when compiling it says :&lt;BR /&gt;&lt;BR /&gt;# gcc tmp.c &lt;BR /&gt;tmp.c:5: conflicting types for `g'&lt;BR /&gt;tmp.c:4: previous declaration of `g'&lt;BR /&gt;tmp.c:5: parse error before "void"&lt;BR /&gt;&lt;BR /&gt;Can you please let me know how the program should look like ?&lt;BR /&gt;&lt;BR /&gt;Regs David</description>
      <pubDate>Wed, 23 Jul 2003 13:49:40 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/gethostid/m-p/3031241#M718899</guid>
      <dc:creator>David_246</dc:creator>
      <dc:date>2003-07-23T13:49:40Z</dc:date>
    </item>
    <item>
      <title>Re: gethostid</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/gethostid/m-p/3031242#M718900</link>
      <description>Hi David:&lt;BR /&gt;&lt;BR /&gt;This will work:&lt;BR /&gt;&lt;BR /&gt;#include &lt;UNISTD.H&gt; &lt;BR /&gt;int long g; &lt;BR /&gt;int main(void) &lt;BR /&gt;{ &lt;BR /&gt;g = gethostid(); &lt;BR /&gt;printf ("The hostid of this machine is : %d\n", g); &lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...&lt;/UNISTD.H&gt;</description>
      <pubDate>Wed, 23 Jul 2003 13:56:30 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/gethostid/m-p/3031242#M718900</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2003-07-23T13:56:30Z</dc:date>
    </item>
    <item>
      <title>Re: gethostid</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/gethostid/m-p/3031243#M718901</link>
      <description>Hi (again) David:&lt;BR /&gt;&lt;BR /&gt;If you want to use ANSI prototypes the code would look like this:&lt;BR /&gt;&lt;BR /&gt;#include &lt;UNISTD.H&gt; &lt;BR /&gt;&lt;BR /&gt;long gethostid(void);&lt;BR /&gt;int long g; &lt;BR /&gt;&lt;BR /&gt;int main(void) &lt;BR /&gt;{ &lt;BR /&gt;  g=gethostid(); &lt;BR /&gt;  printf ("The hostid of this machine is : %d\n",g); &lt;BR /&gt;  return 0;&lt;BR /&gt;} &lt;BR /&gt;&lt;BR /&gt;...note that I added a return code since your main() declaration was of type 'int' not 'void'.&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...&lt;/UNISTD.H&gt;</description>
      <pubDate>Wed, 23 Jul 2003 14:06:21 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/gethostid/m-p/3031243#M718901</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2003-07-23T14:06:21Z</dc:date>
    </item>
    <item>
      <title>Re: gethostid</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/gethostid/m-p/3031244#M718902</link>
      <description>Hhm,&lt;BR /&gt;The actual value of g should be set from inside main(). The declaration should be done before and the printf of course should be %d.&lt;BR /&gt;&lt;BR /&gt;Many, many thanks !!&lt;BR /&gt;&lt;BR /&gt;Regs David</description>
      <pubDate>Wed, 23 Jul 2003 14:09:02 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/gethostid/m-p/3031244#M718902</guid>
      <dc:creator>David_246</dc:creator>
      <dc:date>2003-07-23T14:09:02Z</dc:date>
    </item>
    <item>
      <title>Re: gethostid</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/gethostid/m-p/3031245#M718903</link>
      <description>Hhm,&lt;BR /&gt;The actual value of g should be set from inside main(). The declaration should be done before and the printf of course should be %d.&lt;BR /&gt;&lt;BR /&gt;Many, many thanks !!&lt;BR /&gt;&lt;BR /&gt;Regs David</description>
      <pubDate>Wed, 23 Jul 2003 14:09:20 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/gethostid/m-p/3031245#M718903</guid>
      <dc:creator>David_246</dc:creator>
      <dc:date>2003-07-23T14:09:20Z</dc:date>
    </item>
    <item>
      <title>Re: gethostid</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/gethostid/m-p/3031246#M718904</link>
      <description>The format for printing a long should really be "%ld".  The %d format will break if you compile for 64-bit pointers and longs.&lt;BR /&gt;&lt;BR /&gt;  You don't need to declare gethostid explicitly because it is declared in unistd.h.&lt;BR /&gt;&lt;BR /&gt;  You should include stdio.h because you are calling printf.&lt;BR /&gt;&lt;BR /&gt;  The 11i manual entry for gethostid warns that it will be obsolete someday.  You might want to shift to using confstr with _CS_MACHINE_IDENT or _CS_PARTITION_IDENT.  (Those ident strings get longer on IPF systems.)&lt;BR /&gt;&lt;BR /&gt;#include &lt;UNISTD.H&gt;&lt;BR /&gt;#include &lt;STDIO.H&gt;&lt;BR /&gt;#include &lt;SYS&gt;&lt;BR /&gt;&lt;BR /&gt;int main(void)&lt;BR /&gt;{&lt;BR /&gt;    long g;&lt;BR /&gt;    struct utsname name;&lt;BR /&gt;    char ident[200];&lt;BR /&gt;    g=gethostid();&lt;BR /&gt;    printf ("The hostid of this machine is : %ld\n",g);&lt;BR /&gt;    uname(&amp;amp;name);&lt;BR /&gt;    printf ("The idnumber of this machine is : %s\n", name.idnumber);&lt;BR /&gt;    confstr(_CS_MACHINE_IDENT, ident, sizeof(ident));&lt;BR /&gt;    printf ("The MACHINE_IDENT of this machine is : %s\n", ident);&lt;BR /&gt;    confstr(_CS_PARTITION_IDENT, ident, sizeof(ident));&lt;BR /&gt;    printf ("The PARTITION_IDENT of this partition is : %s\n", ident);&lt;BR /&gt;    return 0;&lt;BR /&gt;} &lt;BR /&gt;&lt;/SYS&gt;&lt;/STDIO.H&gt;&lt;/UNISTD.H&gt;</description>
      <pubDate>Wed, 23 Jul 2003 18:34:37 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/gethostid/m-p/3031246#M718904</guid>
      <dc:creator>Mike Stroyan</dc:creator>
      <dc:date>2003-07-23T18:34:37Z</dc:date>
    </item>
    <item>
      <title>Re: gethostid</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/gethostid/m-p/3031247#M718905</link>
      <description>Thanks for your help !!&lt;BR /&gt;&lt;BR /&gt;Regs David</description>
      <pubDate>Thu, 24 Jul 2003 06:07:45 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/gethostid/m-p/3031247#M718905</guid>
      <dc:creator>David_246</dc:creator>
      <dc:date>2003-07-24T06:07:45Z</dc:date>
    </item>
  </channel>
</rss>

