[問題] 關於struct的讀取與寫入
請教一下各位大大..
struct存取的方是我非常陌生
希望大大們能給我個指示
以下是我寫的函式
struct Data
{
INT32U thing1;
INT32U thing2;
}
struct Data A;
void Write_Data()
{
INT16S fp;
struct Data *txt_addr1=&A;
fp=open((CHAR *)"a:\\Bingo.txt",O_WRONLY|O_CREAT);//開啟nand flash的文件檔
write(fp,(INT32U)txt_addr1,sizeof(A));//將資料的位置寫到nand flash
close(fp);
}
void Read_Data()
{
INT16S fp1;
struct Data *txt_addr1=NULL;
fp1=open((CHAR *)"a:\\Bingo.txt",O_RDONLY|O_CREAT);//開啟nand flash的文件檔
txt_addr1 = (struct Data*)gp_malloc_align(sizeof(A), 4);
read(fp1,(INT32U)txt_addr1,sizeof(A));//將資料的位置從nand flash讀取
A = *txt_addr1;
close(fp1);
}
為何這樣讀出來都是亂碼呢???可以給我個幫助
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 59.120.228.157
※ 編輯: SuperEel 來自: 59.120.228.157 (01/18 13:21)
→
01/18 13:34, , 1F
01/18 13:34, 1F
→
01/18 13:36, , 2F
01/18 13:36, 2F
→
01/18 13:37, , 3F
01/18 13:37, 3F
※ 編輯: SuperEel 來自: 59.120.228.157 (01/18 13:45)
→
01/18 13:45, , 4F
01/18 13:45, 4F
→
01/18 13:47, , 5F
01/18 13:47, 5F
※ 編輯: SuperEel 來自: 59.120.228.157 (01/18 13:48)