0
我嘗試寫一個C應用程序和我使用的後續的代碼,用於讀的16個字符的輸入參數輸入字節轉換參數
int main(int argc, char *argv[])
{
unsigned char input[16];
if (argc != 2) {
fprintf(stderr,
"Usage: %s <input> \n",argv[0]);
return EXIT_FAILURE;
}
strncpy((char *)input, argv[1], 16);
return 0;
}
輸入參數字符是這樣的:「5f52433120d32104」(./所有MyApplication 5f52433120d32104)
我想獲得的輸入字符作爲字節,並把它放到一個數組(圖5f,52,43等),例如:
unsigned char* myByteArray;
由於
你需要將它們轉換爲hexa數嗎? – developer
這是你在找什麼? http://stackoverflow.com/questions/3408706/hexadecimal-string-to-byte-array-in-c – Badministrator