<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="pl-pl">
<link rel="self" type="application/atom+xml" href="https://forum.atnel.pl/feed.php?f=58&amp;t=20139&amp;mode" />

<title>ATNEL tech-forum</title>
<link href="https://forum.atnel.pl/index.php" />
<updated>2018-02-02T21:38:25+01:00</updated>

<author><name><![CDATA[ATNEL tech-forum]]></name></author>
<id>https://forum.atnel.pl/feed.php?f=58&amp;t=20139&amp;mode</id>
<entry>
<author><name><![CDATA[StaryAnoda]]></name></author>
<updated>2018-02-02T21:38:25+01:00</updated>
<published>2018-02-02T21:38:25+01:00</published>
<id>https://forum.atnel.pl/viewtopic.php?t=20139&amp;p=203204#p203204</id>
<link href="https://forum.atnel.pl/viewtopic.php?t=20139&amp;p=203204#p203204"/>
<title type="html"><![CDATA[Jak wypełnić i wyświetlić taką unię ?]]></title>

<content type="html" xml:base="https://forum.atnel.pl/viewtopic.php?t=20139&amp;p=203204#p203204"><![CDATA[
Hej<br /><br />Mam taki kod i w taki sposób chciałbym uzupełniać strukturę i ją wyświetlać, to działa:<br /><br />[syntax=c]#include &lt;stdio.h&gt;<br />#include &lt;stdlib.h&gt;<br /><br />typedef struct <br />{<br />__uint8_t  R;<br />__uint8_t  G;<br />__uint8_t  B;<br />} RGB565;<br /><br />int main (void)<br />{<br />RGB565 Test = <br />{<br />.R = 1,<br />.G = 2,<br />.B = 3<br />};<br /><br />printf(&quot;%d %d %d&quot;, Test.R, Test.G, Test.B);<br />return EXIT_SUCCESS;<br />}[/syntax]<br /><br />W taki sam sposób chciałbym uzupełniać unię i ją wyświetlać czy może mi ktoś podpowiedzieć jak tego dokonać ?<br />[syntax=c]#include &lt;stdio.h&gt;<br />#include &lt;stdlib.h&gt;<br /><br />typedef union<br />{<br />struct<br />{<br />__uint8_t  R : 5;<br />__uint8_t  G : 6;<br />__uint8_t  B : 5;<br />}<br />__uint16_t Word;<br />} RGB565;<br /><br />int main (void)<br />{<br />RGB565 Test = <br />{<br />.R = 1,<br />.G = 2,<br />.B = 3<br />};<br /><br />printf(&quot;Jak wyświeltić unię o nazwie Test ???&quot;);<br />return EXIT_SUCCESS;<br />}[/syntax]<br /><br />Pozdrawiam<br />StaryAnoda<br /><br /><strong><span style="color: #808000">------------------------ [ Dodano po: 22 minutach ]</span></strong><br /><br />Ok już wiem <img src="https://forum.atnel.pl/images/smilies/icon_e_smile.gif" alt=":)" title="Szczęśliwy" /><br /><br />[syntax=c]#include &lt;stdio.h&gt;<br />#include &lt;stdlib.h&gt;<br /> <br />typedef union<br />{<br />        struct<br />        {<br />                __uint8_t  R : 5;<br />                __uint8_t  G : 6;<br />                __uint8_t  B : 5;<br />        }<br />        __uint16_t Word;<br />} RGB565;<br /> <br />int main (void)<br />{<br />        RGB565 Test =<br />        {<br />                        .R = 1,<br />                        .G = 2,<br />                        .B = 3<br />        };<br /> <br />        printf(&quot;%d&quot;Test.Word);<br />        return EXIT_SUCCESS;<br />}[/syntax]<p>Statystyki: Napisane przez <a href="https://forum.atnel.pl/memberlist.php?mode=viewprofile&amp;u=12916">StaryAnoda</a> — 2 lut 2018, o 21:38</p><hr />
]]></content>
</entry>
</feed>