December 26th, 2013, 12:37 PM
-
Confused about TXT file line-feed
I'm wanting to make a txt file, using C, and written to an SD card, consisting of a single long column.
The character I'm writing to that column is defined here:
data_str[0]= ','; //comma delineator
data_str[1]= a + '0';
data_str[2]= b + '0';
data_str[3]= c + '0';
data_str[4]= '\\' ;
data_str[5]= 'r'; //carriage return
data_str[6]= '\\';
data_str[7]= 'n'; // line feed
a comma delineator followed by three BCD digits followed by a "carriage return" and a "line feed"
then I do:
FSfwrite (data_str, 1, 8, pointer);
which creates a TXT file on the SD card looking like this:
,309\r\n,327\r\n,327\r\n,310\r\n,333\r\n,327\r\n,317\r\n,341\r\n,329\r\n,326\r\n,348\r\n,330\r\n,331 \r\n,345\r\n,322\r\n,328\r\n ... and so on
when what I wanted was this
,309
,327
,327
,310
,333
,327
and so on.
obviously the text reader (Windows notepad) is not responding to the \r\n command - it's simply printing it out.
What am I doing wrong please?
December 26th, 2013, 12:47 PM
-
Try
Code:
data_str[4]= '\r' ;
data_str[5]= '\n';
and write 6 bytes instead of 8.
December 26th, 2013, 02:21 PM
-
Thank you Salem! It works perfectly now.
Rick