<?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: A simple C langauage w/ the basic input/output in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/a-simple-c-langauage-w-the-basic-input-output/m-p/2551391#M876541</link>
    <description>Hi,&lt;BR /&gt;&lt;BR /&gt;if you redirect stdout, you need to prompt on stderr:&lt;BR /&gt;&lt;BR /&gt;fprintf(stderr, "Input A = ") ;&lt;BR /&gt;scanf("%d", &amp;amp;instance) ;&lt;BR /&gt;printf("Value= %d \n", instance) ;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;--- Result :&lt;BR /&gt;&lt;BR /&gt;# a.out&lt;BR /&gt;Input A = 23&lt;BR /&gt;Value= 23 &lt;BR /&gt;# a.out &amp;gt; weg&lt;BR /&gt;Input A = 23&lt;BR /&gt;# cat weg&lt;BR /&gt;Value= 23 &lt;BR /&gt;#&lt;BR /&gt;&lt;BR /&gt;Hope this helps&lt;BR /&gt;Volker</description>
    <pubDate>Wed, 11 Jul 2001 13:53:06 GMT</pubDate>
    <dc:creator>Volker Borowski</dc:creator>
    <dc:date>2001-07-11T13:53:06Z</dc:date>
    <item>
      <title>A simple C langauage w/ the basic input/output</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/a-simple-c-langauage-w-the-basic-input-output/m-p/2551390#M876540</link>
      <description>I wrote a very simple C program for any convenience.&lt;BR /&gt;I used scanf to get a standard input and printf for standard output like this.&lt;BR /&gt;&lt;BR /&gt;--- a.out ----&lt;BR /&gt;main()&lt;BR /&gt;{&lt;BR /&gt;int instance ; &lt;BR /&gt;printf("Input A = ") ;&lt;BR /&gt;scanf("%d", &amp;amp;instance)      ;&lt;BR /&gt;printf(%d, instance) ;&lt;BR /&gt;}&lt;BR /&gt;-- end of a.out ----&lt;BR /&gt;&lt;BR /&gt;I'd like to save the output to a file.&lt;BR /&gt;If I run "a.out" using redirection, the result goes to certain file named but I can't see a message "Input A=" at the shell prompt.&lt;BR /&gt;&lt;BR /&gt;For instance,&lt;BR /&gt;# a.out &amp;gt; aaa&lt;BR /&gt;"Input A=" is not displayed.&lt;BR /&gt;So I have to know what question is in advance.&lt;BR /&gt;&lt;BR /&gt;If I execute "a.out" without any parameters, I can enter a value for the question displayed at the shell prompt but I can't save the result to a file.&lt;BR /&gt;&lt;BR /&gt;Any ideas would be helpful.&lt;BR /&gt;</description>
      <pubDate>Wed, 11 Jul 2001 13:27:54 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/a-simple-c-langauage-w-the-basic-input-output/m-p/2551390#M876540</guid>
      <dc:creator>Insu Kim</dc:creator>
      <dc:date>2001-07-11T13:27:54Z</dc:date>
    </item>
    <item>
      <title>Re: A simple C langauage w/ the basic input/output</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/a-simple-c-langauage-w-the-basic-input-output/m-p/2551391#M876541</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;if you redirect stdout, you need to prompt on stderr:&lt;BR /&gt;&lt;BR /&gt;fprintf(stderr, "Input A = ") ;&lt;BR /&gt;scanf("%d", &amp;amp;instance) ;&lt;BR /&gt;printf("Value= %d \n", instance) ;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;--- Result :&lt;BR /&gt;&lt;BR /&gt;# a.out&lt;BR /&gt;Input A = 23&lt;BR /&gt;Value= 23 &lt;BR /&gt;# a.out &amp;gt; weg&lt;BR /&gt;Input A = 23&lt;BR /&gt;# cat weg&lt;BR /&gt;Value= 23 &lt;BR /&gt;#&lt;BR /&gt;&lt;BR /&gt;Hope this helps&lt;BR /&gt;Volker</description>
      <pubDate>Wed, 11 Jul 2001 13:53:06 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/a-simple-c-langauage-w-the-basic-input-output/m-p/2551391#M876541</guid>
      <dc:creator>Volker Borowski</dc:creator>
      <dc:date>2001-07-11T13:53:06Z</dc:date>
    </item>
    <item>
      <title>Re: A simple C langauage w/ the basic input/output</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/a-simple-c-langauage-w-the-basic-input-output/m-p/2551392#M876542</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;You have 3 choices:&lt;BR /&gt;&lt;BR /&gt;1) print your prompt to stderr via fprintf(stderr,&lt;BR /&gt;  That is not considered good form because stderr should only be used for error messages (but you can use it)&lt;BR /&gt;&lt;BR /&gt;2) If you know that you will always be run as interactive, you can prompt to "/dev/tty".&lt;BR /&gt;&lt;BR /&gt;int main(int argc, char *argv[])&lt;BR /&gt;{&lt;BR /&gt;  int cc = 0;&lt;BR /&gt;  FILE *f = NULL;&lt;BR /&gt;&lt;BR /&gt;  f = fopen("/dev/tty","w+");&lt;BR /&gt;  if (f != NULL)&lt;BR /&gt;    {&lt;BR /&gt;      int instance = 0;&lt;BR /&gt;      (void) fprintf(f,"Input A: ");&lt;BR /&gt;      (void) fflush(f);&lt;BR /&gt;      (void) fclose(f)&lt;BR /&gt;  &lt;BR /&gt;       scanf("%d", &amp;amp;instance) ; &lt;BR /&gt;       printf(%d, instance) ;&lt;BR /&gt;     }&lt;BR /&gt;   else cc = 2;&lt;BR /&gt;  return(cc); &lt;BR /&gt;} &lt;BR /&gt; &lt;BR /&gt;3) You could pass a filename as an argument&lt;BR /&gt;int main(int argc, char *argv)&lt;BR /&gt;{&lt;BR /&gt;  int cc = 0;&lt;BR /&gt;  if (argc &amp;gt; 1)&lt;BR /&gt;    {&lt;BR /&gt;       FILE *f = NULL;&lt;BR /&gt;       f = fopen(argv[1],"w");&lt;BR /&gt;       if (f != NULL)&lt;BR /&gt;          { &lt;BR /&gt;            int instance ; &lt;BR /&gt;            printf("Input A = ") ; &lt;BR /&gt;            scanf("%d", &amp;amp;instance) ; &lt;BR /&gt;            fprintf(f,"%d", instance) ;&lt;BR /&gt;            fclose(f);&lt;BR /&gt;          }&lt;BR /&gt;        else cc = 2;&lt;BR /&gt;     }&lt;BR /&gt;   else cc = 1; &lt;BR /&gt;  return(cc);&lt;BR /&gt;} &lt;BR /&gt;&lt;BR /&gt;Clay&lt;BR /&gt;</description>
      <pubDate>Wed, 11 Jul 2001 14:55:05 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/a-simple-c-langauage-w-the-basic-input-output/m-p/2551392#M876542</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2001-07-11T14:55:05Z</dc:date>
    </item>
  </channel>
</rss>

