<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title><![CDATA[Linux Forum &mdash; разные выводы]]></title>
		<link>https://linuxforum.ru/viewtopic.php?id=39097</link>
		<atom:link href="https://linuxforum.ru/extern.php?action=feed&amp;tid=39097&amp;type=rss" rel="self" type="application/rss+xml" />
		<description><![CDATA[Недавние сообщения в теме «разные выводы».]]></description>
		<lastBuildDate>Fri, 19 May 2017 18:47:01 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Re: разные выводы]]></title>
			<link>https://linuxforum.ru/viewtopic.php?pid=455293#p455293</link>
			<description><![CDATA[<p>Не сработал.Все равно такой же результат</p>]]></description>
			<author><![CDATA[null@example.com (trung.bui)]]></author>
			<pubDate>Fri, 19 May 2017 18:47:01 +0000</pubDate>
			<guid>https://linuxforum.ru/viewtopic.php?pid=455293#p455293</guid>
		</item>
		<item>
			<title><![CDATA[Re: разные выводы]]></title>
			<link>https://linuxforum.ru/viewtopic.php?pid=455291#p455291</link>
			<description><![CDATA[<p>Опять же. Не используйте printf. Он работает через буферезированный выхлоп stdout. Юзайте <br /></p><div class="codebox"><pre><code>fprintf (stderr, &quot;My string\n&quot;);</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (marikk)]]></author>
			<pubDate>Fri, 19 May 2017 18:17:04 +0000</pubDate>
			<guid>https://linuxforum.ru/viewtopic.php?pid=455291#p455291</guid>
		</item>
		<item>
			<title><![CDATA[разные выводы]]></title>
			<link>https://linuxforum.ru/viewtopic.php?pid=455289#p455289</link>
			<description><![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>]]></description>
			<author><![CDATA[null@example.com (trung.bui)]]></author>
			<pubDate>Fri, 19 May 2017 17:06:17 +0000</pubDate>
			<guid>https://linuxforum.ru/viewtopic.php?pid=455289#p455289</guid>
		</item>
	</channel>
</rss>
