作者hibiscus520 (周末也會笑)
看板C_and_CPP
標題[問題] 撈struct 中的data
時間Tue Aug 25 00:40:34 2015
開發平台(Platform): (Ex: VC++, GCC, Linux, ...)
VC++2013
額外使用到的函數庫(Library Used): (Ex: OpenGL, ...)
<windows.h> "nvme.h"
問題(Question):
只呼叫SN,但卻連後面的MN & FN 都印出來
看不懂它弄一個temp 在這裡的用意是?
餵入的資料(Input):
預期的正確結果(Expected Output):
只印出SN[20]共 20個char
錯誤結果(Wrong Output):
只呼叫SN,但卻連後面的MN & FN 都印出來
程式碼(Code):(請善用置底文網頁, 記得排版)
if (FALSE == b) {
printf("IdentifyController: NL_IOCTL_IDENTIFY: FAIL\n");
} else {
PADMIN_IDENTIFY_CONTROLLER pIdCtrlr =
(PADMIN_IDENTIFY_CONTROLLER)pMyIoctl->DataBuffer;
UCHAR tmp;
printf("IdentifyController: NL_IOCTL_IDENTIFY: SUCCESS!!!\n" );
printf("\tIdentifyController VID = 0x%x, SSVID = 0x%x \n",
pIdCtrlr->VID, pIdCtrlr->SSVID);
tmp = pIdCtrlr->MN[0];
printf("\tIdentifyController serialNum %s \n", pIdCtrlr->SN);
pIdCtrlr->MN[0] = tmp;
tmp = pIdCtrlr->FR[0];
printf("\tIdentifyController modelNum %s \n", pIdCtrlr->MN);
pIdCtrlr->FR[0] = tmp;
tmp = pIdCtrlr->RAB;
printf("\tIdentifyController firmwarRev %s \n", pIdCtrlr->FR);
pIdCtrlr->RAB = tmp;
}
return TRUE;}
Struct 架構如下
typedef struct _ADMIN_IDENTIFY_CONTROLLER//4096Bytes
{
USHORT VID;
USHORT SSVID;
UCHAR SN[20];
UCHAR MN[40];
UCHAR FR[8];
.
.
.
}
補充說明(Supplement):
麻煩各位前輩了.
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 36.225.46.164
※ 文章網址: https://www.ptt.cc/bbs/C_and_CPP/M.1440434440.A.355.html
→ dritchie: tmp = pIdCtrlr->MN[0]; pIdCtrlr->MN[0] = '\0'; 08/25 00:44
推 LPH66: tmp 開頭的那三行後面應該都有像樓上那樣的另一個指令 08/25 00:49
→ hibiscus520: 哦~這樣就可以輸出20char.然後再把MN[0]還回去 08/25 00:55
→ hibiscus520: 所以即便我設定SN[20]只要沒看到'\0'就會往後印初囉? 08/25 00:56
推 LPH66: 對, 這裡是正好後面是 MN 跟 FR, 一般來說你不知道後面是啥 08/25 08:17
→ hibiscus520: 感謝您。我又更了解了! 08/26 00:17