Я хочу знать значение переменной в C - PullRequest
0 голосов
/ 11 июля 2019

Я новичок в C.

Я хочу знать значение переменной.поэтому я записываю вот так

    #include <stdio.h>

    int main(void) {
        unsigned char cdata[3];
        sprintf(cdata, "%0.2X", 0x42);
        printf(%hhu, cdata)
        return 0;
    }

но есть такие ошибки

prog.c: In function ‘main’:
prog.c:5:10: warning: pointer targets in passing argument 1 of ‘sprintf’ differ in signedness [-Wpointer-sign]
  sprintf(cdata, "%0.2X", 0x42);
          ^~~~~
In file included from prog.c:1:0:
/usr/include/stdio.h:366:12: note: expected ‘char * restrict’ but argument is of type ‘unsigned char *’
 extern int sprintf (char *__restrict __s,
            ^~~~~~~
prog.c:5:17: warning: '0' flag ignored with precision and ‘%X’ gnu_printf format [-Wformat=]
  sprintf(cdata, "%0.2X", 0x42);
                 ^~~~~~~
prog.c:6:9: error: expected expression before ‘%’ token
  printf(%hhu, cdata)
         ^
prog.c:7:2: error: expected ‘;’ before ‘return’
  return 0;
  ^~~~~~
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...