[問題] 指到File pointer資料?

看板C_and_CPP作者 (AJB)時間14年前 (2010/04/05 18:40), 編輯推噓0(003)
留言3則, 3人參與, 最新討論串1/1
想請問一下如果要把file pointer的資料存到array去 但是不能用fread之類的只能用memcpy 有辦法嗎@@? 程式如下 File *ptr; unsigned char *temp; temp = (unsigned char*)malloc(sizeof(unsigned char)*pic_size); ptr = fopen("t.bmp", "rb"); memcpy(temp, ptr, pic_size); free(temp); fclose(ptr); 上面這樣執行會掛掉 爬文發現似乎是File pointer只代表檔案結構 不知道有沒有辦法抓到檔案內容的位址? 感謝回答 -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 140.113.5.239 ※ 編輯: CCAJB 來自: 140.113.5.239 (04/05 18:41)

04/05 19:24, , 1F
mmap ??
04/05 19:24, 1F

04/05 22:15, , 2F
FILE不能這樣用memcpy, 比較好奇為什麼不能用fread??
04/05 22:15, 2F

04/06 17:37, , 3F
你的要求很特別...
04/06 17:37, 3F
文章代碼(AID): #1BkRuefN (C_and_CPP)