<?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=4&amp;t=7862&amp;mode" />

<title>ATNEL tech-forum</title>
<link href="https://forum.atnel.pl/index.php" />
<updated>2014-07-23T07:58:12+01:00</updated>

<author><name><![CDATA[ATNEL tech-forum]]></name></author>
<id>https://forum.atnel.pl/feed.php?f=4&amp;t=7862&amp;mode</id>
<entry>
<author><name><![CDATA[filip]]></name></author>
<updated>2014-07-23T07:58:12+01:00</updated>
<published>2014-07-23T07:58:12+01:00</published>
<id>https://forum.atnel.pl/viewtopic.php?t=7862&amp;p=88553#p88553</id>
<link href="https://forum.atnel.pl/viewtopic.php?t=7862&amp;p=88553#p88553"/>
<title type="html"><![CDATA[Re: Funkcja strncpy]]></title>

<content type="html" xml:base="https://forum.atnel.pl/viewtopic.php?t=7862&amp;p=88553#p88553"><![CDATA[
No tak, strasznie głupi błąd. Dziękuję za pomoc <img src="https://forum.atnel.pl/images/smilies/icon_e_smile.gif" alt=":)" title="Szczęśliwy" /><p>Statystyki: Napisane przez <a href="https://forum.atnel.pl/memberlist.php?mode=viewprofile&amp;u=1548">filip</a> — 23 lip 2014, o 07:58</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[charsz]]></name></author>
<updated>2014-07-23T07:53:12+01:00</updated>
<published>2014-07-23T07:53:12+01:00</published>
<id>https://forum.atnel.pl/viewtopic.php?t=7862&amp;p=88551#p88551</id>
<link href="https://forum.atnel.pl/viewtopic.php?t=7862&amp;p=88551#p88551"/>
<title type="html"><![CDATA[Re: Funkcja strcnpy]]></title>

<content type="html" xml:base="https://forum.atnel.pl/viewtopic.php?t=7862&amp;p=88551#p88551"><![CDATA[
strncpy dziala poprawnie. <br />[syntax=c]char adress&#91;ADRESS_SIZE+1&#93;;[/syntax]<br /><br />inicjujesz tablice adress i nie jestes w stanie przewidziec jaki bedzie miala zawartosc.<br />jak wkopiujesz do niej dane:<br />[syntax=c]strncpy(adress, buf_ptr, ADRESS_SIZE);[/syntax]<br />to musisz jeszcze umiescic znak konca stringa '\0' po oczekiwanym ciagu znakow:<br />[syntax=c]adress&#91;ADRESS_SIZE&#93; = '\0';[/syntax]<p>Statystyki: Napisane przez <a href="https://forum.atnel.pl/memberlist.php?mode=viewprofile&amp;u=926">charsz</a> — 23 lip 2014, o 07:53</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[filip]]></name></author>
<updated>2014-07-23T07:41:11+01:00</updated>
<published>2014-07-23T07:41:11+01:00</published>
<id>https://forum.atnel.pl/viewtopic.php?t=7862&amp;p=88550#p88550</id>
<link href="https://forum.atnel.pl/viewtopic.php?t=7862&amp;p=88550#p88550"/>
<title type="html"><![CDATA[Funkcja strncpy]]></title>

<content type="html" xml:base="https://forum.atnel.pl/viewtopic.php?t=7862&amp;p=88550#p88550"><![CDATA[
Chcę napisać funkcję do dzielenia ramki UART, ale mam pewien problem z funkcją strncpy. Piszę na razie program konsolowy, żeby szybciej śledzić zmiany i poprawność kodu. Kopiuje ona złą ilość danych do bufora:<br />[syntax=c]#include &lt;stdio.h&gt;<br />#include &lt;stdlib.h&gt;<br />#include &lt;string.h&gt;<br /><br />#define UART 32<br />#define START_SIZE 2<br />#define ADRESS_SIZE 2<br />#define DATA_SIZE 1<br /><br />int main(int argc, char *argv&#91;&#93;) {<br />int status;<br />char buf&#91;&#93;=&quot;XXEDPOLKOSDMR&quot;;<br />printf(&quot;%s\n&quot;,buf);<br />char adress&#91;ADRESS_SIZE+1&#93;;<br />char data&#91;DATA_SIZE+1&#93;;<br />char *buf_ptr = buf;<br /><br />while( buf_ptr &lt; buf + UART ){<br />buf_ptr += 1;<br />if( strncmp(&quot;XX&quot;,buf_ptr,2) ){<br />printf(&quot;poczatek ramki!\n&quot;);<br />status=1;<br />break;<br />}<br />}<br />buf_ptr = buf+START_SIZE;<br />printf(&quot;bufor: %s\n&quot;,buf_ptr);<br />if( status ){<br />printf(&quot;bufor przed odjeciem adresu: %s\n&quot;,buf_ptr);<br />strncpy(adress, buf_ptr, ADRESS_SIZE);<br />printf(&quot;adres: %s \n&quot;,adress);<br />buf_ptr += ADRESS_SIZE;<br />printf(&quot;bufor po odjeciu adresu: %s\n&quot;,buf_ptr);<br />strncpy(data, buf_ptr, DATA_SIZE);<br />printf(&quot;data: %s \n&quot;,data);<br />buf_ptr += DATA_SIZE;<br />printf(&quot;bufor po odjeciu danych: %s\n&quot;,buf_ptr);<br />}<br />getchar();<br />return 0;<br /><br />}[/syntax]<br />Czego efektem jest:<br /><a href="http://forum.atnel.pl/_obrazki/o/1548/8687ed2b4720d85f6c86dbfa6fdb36e3.jpg"  class="postlink"><img src="http://forum.atnel.pl/_obrazki/o/thumb/1548/8687ed2b4720d85f6c86dbfa6fdb36e3.jpg" alt="Obrazek" /></a><br />Prześledziłem już parę razy cały kod i opis funkcji, ale dalej nie mogę znaleźć błędu.<p>Statystyki: Napisane przez <a href="https://forum.atnel.pl/memberlist.php?mode=viewprofile&amp;u=1548">filip</a> — 23 lip 2014, o 07:41</p><hr />
]]></content>
</entry>
</feed>