<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Linux Forum &mdash; разные выводы]]></title>
	<link rel="self" href="https://linuxforum.ru/extern.php?action=feed&amp;tid=39097&amp;type=atom" />
	<updated>2017-05-19T18:47:01Z</updated>
	<generator>PunBB</generator>
	<id>https://linuxforum.ru/viewtopic.php?id=39097</id>
		<entry>
			<title type="html"><![CDATA[Re: разные выводы]]></title>
			<link rel="alternate" href="https://linuxforum.ru/viewtopic.php?pid=455293#p455293" />
			<content type="html"><![CDATA[<p>Не сработал.Все равно такой же результат</p>]]></content>
			<author>
				<name><![CDATA[trung.bui]]></name>
				<uri>https://linuxforum.ru/profile.php?id=40904</uri>
			</author>
			<updated>2017-05-19T18:47:01Z</updated>
			<id>https://linuxforum.ru/viewtopic.php?pid=455293#p455293</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: разные выводы]]></title>
			<link rel="alternate" href="https://linuxforum.ru/viewtopic.php?pid=455291#p455291" />
			<content type="html"><![CDATA[<p>Опять же. Не используйте printf. Он работает через буферезированный выхлоп stdout. Юзайте <br /></p><div class="codebox"><pre><code>fprintf (stderr, &quot;My string\n&quot;);</code></pre></div>]]></content>
			<author>
				<name><![CDATA[marikk]]></name>
				<uri>https://linuxforum.ru/profile.php?id=20103</uri>
			</author>
			<updated>2017-05-19T18:17:04Z</updated>
			<id>https://linuxforum.ru/viewtopic.php?pid=455291#p455291</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[разные выводы]]></title>
			<link rel="alternate" href="https://linuxforum.ru/viewtopic.php?pid=455289#p455289" />
			<content type="html"><![CDATA[<p>запустил код на сайте ideone.com<br /></p><div class="codebox"><pre><code>#include &lt;sys/types.h&gt;
#include &lt;unistd.h&gt;
#include &lt;stdio.h&gt;

int main()
{
    int fd[2], result;
    size_t size;
    char resstring[14];

    if(pipe(fd) &lt; 0)
         {
        printf(&quot;Can\&#039;t create pipe\n&quot;);
        exit(-1);
         }

    result = fork();
    if(result &lt; 0)
        {
        printf(&quot;Can\&#039;t fork child\n&quot;);
        exit(-1);
         }
    else if (result &gt; 0)
         {
        /* процесс-предок*/
        close(fd[0]);
    printf(&quot;Father is going to send a letter to his beloved son...\n&quot;);
        size = write(fd[1], &quot;Hello, world!&quot;, 14);
        if(size != 14)
            {
            printf(&quot;Can\&#039;t write all string\n&quot;);
            exit(-1);
            }
        
        close(fd[1]);
    printf(&quot;Father wants his letter to reach the final destination.\n&quot;);
        printf(&quot;Parent exit\n&quot;);
         }
    else {
        /* процесс - потомок*/
        close(fd[1]);
    printf(&quot;Son decides to check his inbox...\n&quot;);    
        size = read(fd[0], resstring, 14);
        if(size &lt; 0)
            {
            printf(&quot;Can\&#039;t read string\n&quot;);
            exit(-1);
            }
    printf(&quot;Son has just recieved a nice letter from his father.\n&quot;);
    printf(&quot;Here it is:\n&quot;);
        printf(&quot;\&quot;%s\&quot;\n&quot;,resstring);    
        close(fd[0]);
         }    
    getchar();
    return 0;
}</code></pre></div><br /><p>Результат:</p><p>Father is going to send a letter to his beloved son...<br />Father wants his letter to reach the final destination.<br />Parent exit<br />Son decides to check his inbox...<br />Son has just recieved a nice letter from his father.<br />Here it is:<br />&quot;Hello, world!&quot;</p><br /><p>а&nbsp; когда запустил код под линуксе<br />такой результат:<br />Father is going to send a letter to his beloved son...<br />Son decides to check his inbox...<br />Father wants his letter to reach the final destination.<br />Parent exit<br />Son has just recieved a nice letter from his father.<br />Here it is:<br />&quot;Hello, world!&quot;</p><br /><p>В чем же проблем??<br />Мне надо чтобы код запустил под линуксом выдал результат как на сайте ideone.com<br />т.е<br />Father is going to send a letter to his beloved son...<br />Father wants his letter to reach the final destination.<br />Parent exit<br />Son decides to check his inbox...<br />Son has just recieved a nice letter from his father.<br />Here it is:<br />&quot;Hello, world!&quot;<br />Исправьте,плиз</p>]]></content>
			<author>
				<name><![CDATA[trung.bui]]></name>
				<uri>https://linuxforum.ru/profile.php?id=40904</uri>
			</author>
			<updated>2017-05-19T17:06:17Z</updated>
			<id>https://linuxforum.ru/viewtopic.php?pid=455289#p455289</id>
		</entry>
</feed>
