[En-Nut-Discussion] Reading from file

Ernst Stippl ernst at stippl.org
Fri Oct 5 18:12:58 CEST 2007


Hi Maciek!

        FILE *stronka = NULL;
...
                                fprintf_P(stdout, PSTR("%s"), data);
//                                fwrite(data, 1, n, stronka);

I guess the 12 chars are printed by the fprintf_P and then the fwrite to
"stronka" - which is "NULL" - does no good .....

Regards
ernst


-----Ursprüngliche Nachricht-----
Von: en-nut-discussion-bounces at egnite.de
[mailto:en-nut-discussion-bounces at egnite.de] Im Auftrag von Maciek
Gesendet: Donnerstag, 04. Oktober 2007 17:19
An: Ethernut User Chat (English)
Betreff: Re: [En-Nut-Discussion] Reading from file

Thx for help! It really works! But there is another problem...
If you take a look at my first post about reading from file, then you can 
see, that I commented one line - it is that one with fwrite function. So... 
if I uncomment that line then 12 first characters are displayed (including 
"\n" and "\r") and after that my whole device restarts. I really don't know 
why.

Any ideas?

Thx!

Maciek


----- Original Message ----- 
From: "Harald Kipp" <harald.kipp at egnite.de>
To: "Ethernut User Chat (English)" <en-nut-discussion at egnite.de>
Sent: Thursday, October 04, 2007 9:09 AM
Subject: Re: [En-Nut-Discussion] Reading from file


Oops, I forgot

n = _read(fd, data, size - 1);

Harald Kipp schrieb:
> Maciek,
>
> you missed to add the terminating '\x00' character.
>
> Maciek schrieb:
>
>>                         n = _read(fd, data, size);
>>
>>
> data[n] = 0;
>
>>                                 fprintf_P(stdout, PSTR("%s"), data);
>>
>>
> Harald
>
> PS. please send plain text to the list. See
> http://www.expita.com/nomime.html
>
> _______________________________________________
> http://lists.egnite.de/mailman/listinfo/en-nut-discussion
>
>


-- 
egnite Software GmbH
Erinstr. 9
44575 Castrop-Rauxel
Germany

Fon +49 (0)23 05-44 12 56
Fax +49 (0)23 05-44 14 87

http://www.egnite.de/
http://www.ethernut.de/

Handelsregister: Amtsgericht Dortmund HRB 19783
USt-IdNr.: DE 189520047
Geschäftsführung: Harald Kipp


_______________________________________________
http://lists.egnite.de/mailman/listinfo/en-nut-discussion


_______________________________________________
http://lists.egnite.de/mailman/listinfo/en-nut-discussion



-- 
No virus found in this incoming message.
Checked by AVG Free Edition. 
Version: 7.5.488 / Virus Database: 269.14.1/1050 - Release Date: 04.10.2007
17:03





More information about the En-Nut-Discussion mailing list